jck Posted July 12, 2007 Share Posted July 12, 2007 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 More sharing options...
jck Posted July 12, 2007 Author Share Posted July 12, 2007 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 More sharing options...
jck Posted July 13, 2007 Author Share Posted July 13, 2007 *bump* Link to comment https://forums.phpfreaks.com/topic/59705-rating-system-help/#findComment-296985 Share on other sites More sharing options...
teng84 Posted July 13, 2007 Share Posted July 13, 2007 The question is nor clear where do you want to increment in the? Link to comment https://forums.phpfreaks.com/topic/59705-rating-system-help/#findComment-297005 Share on other sites More sharing options...
jck Posted July 13, 2007 Author Share Posted July 13, 2007 in the jable where jokes are there Link to comment https://forums.phpfreaks.com/topic/59705-rating-system-help/#findComment-297007 Share on other sites More sharing options...
teng84 Posted July 13, 2007 Share Posted July 13, 2007 maybe you need the update clause ? Link to comment https://forums.phpfreaks.com/topic/59705-rating-system-help/#findComment-297019 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.