Reputation: 5432
I'm creating a jokes website. Each joke is stored as a record in mysql db. I'm trying to develop a vote link which increments the joke record's "score" column when a "vote" link is clicked.
I'm just hoping for some general direction as to how to do this... I'm planning on using jquery's ajax to send the joke's id to a php page to process. I'm just not sure how exactly to process it... something like this?
$id = $_POST['id']
mysql_query("UPDATE jokes SET score='++' WHERE id='$id'");
Each joke will be within a uniquely identified <div>
(the id= is generated with the record's unique id).
Thanks a lot!
Upvotes: 0
Views: 413
Reputation: 9174
As per "The Scrum Meister"'s suggestion
mysql_query("UPDATE jokes SET score= score + 1 WHERE id='".mysql_real_escape_string($id)."'");
Upvotes: 3
Reputation: 22018
mysql_query("UPDATE jokes SET score= score + 1 WHERE id='$id'");
Upvotes: 4