Member Avatar for Mayank23

i made a rating system, however each time i would click on like for the first name, it counts the vote for the second name, and when click on the like for the second name, it still counts the vote for the second name. please help.

<?php include 'connection/connection.php'; $selection = "SELECT * FROM testrating"; $result = mysql_query($selection); while($row=mysql_fetch_array($result)) { $id = $row['ID']; echo $row['name']." ".$row['name_votes']."<a href=\"index.php?id=$id\">like</a>"; $enterrating = "UPDATE testrating SET name_votes=name_votes +1 WHERE ID = \"$id\" "; } ?> <?php mysql_query($enterrating); ?>
Member Avatar for Mayank23

nvm, i got it to work after playing around for little bit.
i got it to work by using another php file to add 1 to the name.
so like,
i included this like.php

<?php include 'connection/connection.php'; $id = $_GET['id']; // using mysql query to get current ratings $enterrating = "UPDATE testrating SET name_votes=name_votes +1 WHERE ID = \"$id\" "; mysql_query($enterrating); ?>
Member Avatar for Mayank23

could someone explain why it wouldnt work when i did not have another file.
thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.