PDA

View Full Version : Could someone help please?



JohnnyX
01 Nov 2006, 02:29 AM
I have created a dynamic web page at www.cashsurveysnow.com/test3.php
The tables are generated from mysql database. I am in the process of developing the user rating system and have run into a snag. I have everything working as far as the form and input user selection to database and even shows the updated rating on the database update page, but I can't get the rating to display back on the main page /test3.php...
anybody want to take a stab?
This is a copy of the code.


$sql = "SELECT * FROM surveycompany ORDER BY csn_rating ASC";
$result = mysql_query($sql,$connection) or die (mysql_error());

while($row = mysql_fetch_array($result)) {

$id = $row['id'];
$compname = $row['compname'];
$description = $row['description'];
$link = $row['link'];
$contactinfo = $row['contactinfo'];
$suppphone = $row['suppphone'];
$suppemail = $row['suppemail'];
$verified = $row['verified'];
$csn_rating = $row['csn_rating'];
$rating = $row['rating'];
$num_votes = $row['num_votes'];

$display_block .= "<br>
<table bgcolor=#ACBFD3 width=100% cellpadding=3 cellspacing=0 border=0>
<tr>
<table border=1 cellspacing=0 cellpadding=1 width=100%>

<tr>
<td colspan=4 align=left><font color=black><b><a href=$link>$compname</b></font></a></td>
<td align=center><b>Verified:$verified]</b></td></tr>
<tr><td colspan=4 align=left>$description</td><td align=center>
<i>CSN Rating:#<b>$csn_rating</b></i><br>
<i>User Rating:
<form action=test3rate.php?id=$id method=post name=rating id=rating>
Rate this Company:<br>
<select name=rating>
<option value=5 selected>5-Excellent!</option>
<option value=4>4-Good</option>
<option value=3>3-OK</option>
<option value=2>2-Awful!</option>
<option value=1>1-RUN AWAY!</option>
</select>
<input name=$id type=hidden id=$id value=$id>
<input name=cmd type=hidden id=cmd value=do _rating>
<input type=submit name=Submit value=Go!>
</form>
</td></tr><tr><td width=17% align=center><B>Region</B></td>

<td width=17% align=center><B>Type</B></td>
<td width=17% align=center><B>Reward</B></td>

<td width=17% align=center><B>Referral</B></td>
<td width=32% align=center><B>Notes</B></td>
</tr>

<tr><td width=17% align=center>USA</td>

<td width=17% align=center> </td>
<td width=17% align=center> </td>

<td width=17% align=center><b><a href=$link>Link</b></td>
<td width=32% align=center><font size=1> </font></td>
</tr>
</table>";
}

?>


The part where the trouble is:
I have to get the current $rating * $num_votes = $total
then $total / $num_votes to get the current user rating then display it in the $display_block just after User Rating: