Jump to content

rating system help


jck

Recommended Posts

presently my rating system is i store id ,userid and raing values in a table and when any article is viewed it calculates the rating instantly but what i woud like to do is store 2 new columns in jokes table and inspite of the first system continuing the value in the jokes table of rating should increase based o the vote(1-5

) and the rate count should increase by 1 could u please tell me how to do it

Link to comment
https://forums.phpfreaks.com/topic/59705-rating-system-help/
Share on other sites

this is the unsuccesfull code i used for that

<?
require_once("conn.php");

//check the user ???
$q1 = "select * from dd_rating where ItemID = '$_POST[itemID]' and username = '$_SESSION[username]' ";
$r1 = mysql_query($q1) or die(mysql_error());

if(mysql_num_rows($r1) == '0')
{

$q2 = "insert into dd_rating set 
				ItemID = '$_POST[itemID]',
				Rating = '$_POST[rr]',
				username = '$_SESSION[username]' ";
mysql_query($q2) or die(mysql_error());

       $request = mysql_query("
	SELECT rt.rating, rt.ratecount
	FROM dd_items AS rt
	WHERE ItemID = $_GET['ItemID']") or die(mysql_error());

       while($row = mysql_fetch_row($request))
{
    $rating   = $row['rating'];
    $ratecount = $row['ratecount'];
    
} 
     $rating = $rating + $_POST[rr];
     $ratecount='$ratecount' +1 ;

header("location:$_SERVER[HTTP_REFERER]&rate_error=n");


}
else
{
header("location:$_SERVER[HTTP_REFERER]&rate_error=y");
}


?>

Link to comment
https://forums.phpfreaks.com/topic/59705-rating-system-help/#findComment-296741
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.