Entry
How do I store a count on a thumbs up and thumbs down rating for a site?
Sep 4th, 2000 19:20
Craig Fratrik, Terry Morris,
1) Create a table with a create statement similiar to the one below i
assume that you have selected your database and in the php connected:
<MYSQL>
CREATE TABLE ratings (thmbup int, thmbdn int);
2) Insert a table entry like:
<MYSQL>
INSERT INTO ratings (thmbup, thmbdn) VALUES (0,0);
3) Query the data like:
<PHP>
$q = "SELECT * FROM ratings;";
$results = mysql_query($q) or die("BAD QUERY: $q);
$result = mysql_fetch_array($results);
$thumbsup = $result['thmbup'];
$thumbsdown = $resutl['thmbdn'];
4) To change the data you first must delet the old data after querying
it from #3:
<PHP>
$q = "DELETE FROM ratings;";
mysql_query($q) or die("BAD QUERY: $q");
$q = "INSERT INTO ratings (thmbup, thmbdn) VALUES ($newthumbsup, ";
$q .= "$newthumbsdown);";
mysql_query($q) or die("BAD QUERY: $q");