Jump to content

Please help with rating system ???


tommyda

Recommended Posts

I am developing a user rating system for a project but I am having problems.

 

What the script below should do is display the rating for each review but instead it is displaying the same rating on each row.

 

 

hope that made sense, heres the code (I have commented where the problem is)

This is where the problem is:

while($rrow = mysql_fetch_array( $reviewq )) {
$u_id = $rrow['userid'];

$userrating = mysql_query("SELECT service_rating FROM ratings WHERE u_id = '$u_id' && s_id = $s_id")
or die(mysql_error());
$urrow = mysql_fetch_array($userrating);
$urating = $urrow['service_rating'];
echo '<a href="user_review.php?rid='.$rrow['id'].'">'.$rrow['title'].'</a> - User Rating: '.$urating.'</br>';

};

Full code:

<?
include 'inc/mysql_con.php';
$s_id = $_GET['sid'];
$siteq = mysql_query("SELECT * FROM sites WHERE id = '$s_id'") 
or die(mysql_error());
$reviewq = mysql_query("SELECT * FROM reviews WHERE s_id = '$s_id'") 
or die(mysql_error());
$srow = mysql_fetch_array( $siteq );
//$rrow = mysql_fetch_array( $reviewq );
?>
<head>
<title><? echo $srow['title'];?> Review</title>
</head>

<body>
<p>Site: <a href="<? echo $srow['url'];?>"><? echo $srow['name']; 

$ratingq = mysql_query("SELECT avg(service_rating) AS avg_rating FROM ratings WHERE s_id = '$s_id' ") 
or die(mysql_error());
$rarow = mysql_fetch_array( $ratingq );
$rounded = round($rarow['avg_rating']);

echo'</a> </br>Average Rating: '.$rounded.'/10';

?></p>
<p>Our Review: 
  <? echo $srow['desc'];?>
</p>
<p>User Reviews:</br> 
// This is where the problem is 
<? while($rrow = mysql_fetch_array( $reviewq )) {
$u_id = $rrow['userid'];

$userrating = mysql_query("SELECT service_rating FROM ratings WHERE u_id = '$u_id' && s_id = $s_id")
or die(mysql_error());
$urrow = mysql_fetch_array($userrating);
$urating = $urrow['service_rating'];
echo '<a href="user_review.php?rid='.$rrow['id'].'">'.$rrow['title'].'</a> - User Rating: '.$urating.'</br>';

};?>
</p>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.