PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die("Unable to select database");
$query = "SELECT * FROM video WHERE id='$id'";
$result = mysql_query($query);
while ($r = mysql_fetch_array($result)) {
$vote = $_GET['vote'];
$votetotal = $r["votetotal"];
$totalvotes = $r["totalvotes"];
$insvotetotal = $votetotal + $vote;
$instotalvotes = $totalvotes + 1;
mysql_query("UPDATE video SET (votetotal='$insvotetotal', totalvotes='$instotalvotes') WHERE id='$id'");
mysql_close();
echo "Thank you for your vote! Current vote: $votetotal/$totalvotes <B>";
}
?>
Not sure what i'm doing wrong, but the votetotal and totalvotes fields won't move from 0 in my database.
FYI, votetotal is the accumulated total of all votes. totalvotes is the total number of votes.