0

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);

?>
1
Contributor
2
Replies
3
Views
5 Years
Discussion Span
Last Post by Mayank23
0

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);









?>
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.