Im having a problem in my Rating Mod in which when you rate a user up the number does not go up.
For example. The users rating is "0" and if you rate them up it says You haver gievn the user a good rating , however i go back to their profile and their rating is still 0.
Can Anyone help me ? Am i missing something ?
And the mod is:
rating.php
<?php
include "globals.php";
$ID = (int) ($_GET['ID']);
$action = $_GET['action'];
$ar=$db->query("SELECT * FROM usrate WHERE rater={$userid} AND rated={$ID}");
if($db->fetch_row($ar))
{
echo 'You Already Rated This Person Today';
$h->endpage();
exit;
}
switch($action)
{
case 'goodrating':
goodrating();
break;
case 'badrating':
badrating();
break;
}
if(!$ID)
{
echo "Error - invaild player id.";
$h->endpage();
exit;
}
if(!$action)
{
echo "Error - invaild action.";
$h->endpage();
exit;
}
function goodrating()
{
global $ir,$userid;
$ID = $_GET['ID'];
if($ID == $userid)
{
echo 'You cannot rate yourself.';
$h->endpage();
exit;
}
else
{
$result = mysql_query("SELECT * FROM users WHERE userid='{$ID}'");
while($row = mysql_fetch_row($result))
{
$ratings = $row['ratings'];
}
mysql_query("UPDATE users SET goodratings = {$gratings}+1 WHERE userid='{$ID}'");
mysql_query("INSERT INTO usrate values ({$userid},{$ID})");
echo 'You gave the user a good rating';
}
}
function badrating()
{
global $ir,$userid;
$ID = $_GET['ID'];
if($ID == $userid)
{
echo 'You cannot rate yourself.';
$h->endpage();
exit;
}
else
{
$result = mysql_query("SELECT * FROM users WHERE userid='{$ID}'");
while($row = mysql_fetch_row($result))
{
$ratings = $row['ratings'];
}
mysql_query("UPDATE users SET badratings = {$bratings}+1 WHERE userid='{$ID}'");
mysql_query("INSERT INTO usrate values ({$userid},{$ID})");
echo 'You gave the user a bad rating';
}
}
$h->endpage();
?>