im trying to make a rating system where the user can either "like" or "dislike" a picture. but for testing im just using 2 names from a mysql database. once the user hits like, the query will add 1 to the column "name_votes", and would subtract 1 if the user hits dislike.i need help on matching the button to the name, so when the user hits like, it will add one to that name. also, when i hit like, it doesn't add 1 to the database. i need help with that.
-i have not done the dislike code yet, i have just done the like code.
<?php
$con = mysql_connect("localhost","root","");
mysql_select_db("images",$con);
function like(){
$like = "UPDATE \"testrating\" SET \"name_votes\"=\"name_votes\" +1 WHERE \"id\" = \"button\" ";
mysql_query($like);
}
$selection = "SELECT * FROM testrating";
$result = mysql_query($selection);
while($row = mysql_fetch_array($result))
{
echo $row["name"]."<form method=\"post\" action=\"\"> <input type=\"button\" id = \"button++\" name = \"crave\" value=\"Crave\" </form></br>";
}
if(isset($_POST['crave']))
{
like();
}