I am building a site that will allow visitors to review and rate certain books. The page that is giving me problems is the page that displays the books and the ratings that the book has recieved (average rating).
Well I have played with this thing till I am blue in the face and I just know it is something simple.
Could someone look over the code below and tell me what I am doing?
<table width = '100%' border ='0' bgcolor='#FFFFFF'>
<tr>
<td width = '30%'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'><b>Book Title</b></font></td>
<td width = '25%'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'><b>Reviews/Rating</b></font></td>
<td width = '40%'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'><b>Description</b></font></td>
<td width = '5%'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'><b>Review?</b></font></td>
</tr>
");
######################################
## Execute queries to get the books ##
######################################
$loopQuery = "SELECT * FROM $TableName_10 WHERE book_status = '1'";
$loopResult = mysql_query($loopQuery, $Link1);
#####################
## Print Books Out ##
#####################
WHILE ($row = mysql_fetch_array($loopResult))
{
$reviewQuery = "SELECT rating FROM $TableName_11 WHERE book_id = '$book_id'";
$reviewResult = mysql_query($reviewQuery, $Link1);
$reviewArray = mysql_fetch_array($reviewResult);
//Figure out the rating.
$votes = mysql_num_rows($reviewResult);
IF ($votes > 0)
{
$tally = 0;
for($i = 0; $i <= $votes; $i++)
{
$tally = $reviewArray[$i] + $tally;
}
$average = $tally / $votes;
}
PRINT("
<tr bgcolor = '#c8c4c2'>
<td><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>$row[book_title]</font></td>
<td><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>");
IF($votes <= 0)
{
Print("votes = $votes<br>tally = $tally<br>average = $average");
}
ELSEIF($average <= '1')
{
PRINT("<img src='http://www.spiderkeeper.com/images/icons/3star2a.gif' border='0' height = '' width = ''>");
}
ELSEIF($average > '1' && $average <= '2')
{
PRINT("<img src='http://www.spiderkeeper.com/images/icons/3star2a.gif' border='0' height = '' width = ''>");
}
ELSEIF($average > '2' && $average <= '3')
{
PRINT("<img src='http://www.spiderkeeper.com/images/icons/3star2a.gif' border='0' height = '' width = ''>");
}
ELSEIF($average > '3' && $average <= '4')
{
PRINT("<img src='http://www.spiderkeeper.com/images/icons/3star2a.gif' border='0' height = '' width = ''>");
}
ELSEIF($average > '4' && $average <= '5')
{
PRINT("<img src='http://www.spiderkeeper.com/images/icons/3star2a.gif' border='0' height = '' width = ''>");
}
PRINT("</font></td>
<td><font size='2' face='Verdana, Arial, Helvetica, sans-serif'>$row[book_description]</font></td>
<td align ='center'><font size='2' face='Verdana, Arial, Helvetica, sans-serif'><a href ='http://www.spiderkeeper.com/RESOURCES/book_review.php?book_id=$row[book_id]'>
<img src='http://www.spiderkeeper.com/images/icons/chklst.gif' border = '0'></a></font>
</td>
</tr>
");
}
#####################################
## End and link to Add a book page ##
#####################################
PRINT("</table>");