Hi,
I'm a MySQL newbie taking on a huge project for myself... and I'm doing pretty well (it's almost done), but there's just one roadblock in my way right now.
I have a DB of items, and each item has its own built in rating system (good or bad), the rating system works fine, and it records the user's IP address, along with the listing ID they voted on in a seperate table.
I need the voting script to cross reference the user's IP with that IP table each time they vote, so that if their IP exists for item ID say... 3, then their vote isn't counted.
For reference, I'll post the rating part of the script I have now... if anyone can help me do that, I'd be really grateful!
PHP Code:
<?
//******************
// If the Vote is Good
//******************
if ($vote == "good") {
$query = "INSERT INTO ip (listingid,ip) VALUES ('$id','$ip')";
$result = mysql_query($query)
or die ("Couldn't Add IP");
$newrating = $row[goodrating] + 1;
$query = "UPDATE host SET goodrating='$newrating' WHERE id='$id'";
$result = mysql_query($query)
or die ("Couldn't Update Good Vote Status</a>");
?>
Thank you. Your praise for this Web
Hosting Company has been recorded.
You can <a href=listing.php?id=<? echo
$id?>>click here</a> to return to <?
echo $row[hostname] ?>.
<?
//******************
// If the Vote is Bad
//******************
} elseif ($vote == "bad") {
$query = "INSERT INTO ip (listingid,ip) VALUES ('$id','$ip')";
$result = mysql_query($query)
or die ("Couldn't Add IP");
$newrating = $row[badrating] + 1;
$query = "UPDATE host SET badrating='$newrating' WHERE id='$id'";
$result = mysql_query($query)
or die ("Couldn't Update Bad Vote Status</a>");
?>
Thank you. Your "bad" rating for this
Web Hosting Company has been recorded.
You can <a href=listing.php?id=<? echo
$id?>>click here</a> to return to <? echo
$row[hostname] ?>.
<?
//******************
// If the Vote is Nowhere in Sight
//******************
} else {
echo "No vote specified";
}
?>