Forum Moderators: coopster
function display_comments()
{
global $id, $link;
$cresult = mysql_query("SELECT * FROM comments where productid = '$id' order by id asc", $link) or die ("vquery 1: " . mysql_error());
$num_rows = mysql_num_rows($cresult);
if ($num_rows >= 1)
{
echo '<table summary="" border="1">';
while($crow = mysql_fetch_array($cresult))
{
$color = "blue";
if($color == "blue")
{
$color = "red";
##Close if
}
return '<tr bgcolor="'.$color.'"><td>'.$crow['title'].'<br>'.$crow['uname'].'</td></tr><tr bgcolor="'.$color.'"><td>'.$crow['review'].'</td></tr><tr bgcolor="'.$color.'"><td>'.$crow['rating'].'</td></tr>';
##Close while loop
}
echo '</table>';
##Close if
}
else
{
echo 'There are no comments for this item.';
}
}
But even if there are 20 rows it only displays one, how can I get the correct output?
Maybe you should try an echo statment there instead.
why do you have this?
while($crow = mysql_fetch_array($cresult))
{
$color = "blue";
if($color == "blue")
{
$color = "red";
##Close if
}
increment the $x each time the while statment cycles
as for the color
$color = "blue";
while($crow = mysql_fetch_array($cresult))
{
blaa blaa blaa
if($color == "blue")
$color = "red";
else
$color= "blue";
}
I think
and then where you call your function
$foo=display_comments();
then you will need something that will print off each of the array values
my best sugestion is to change it to an include file and use echo. if it is printing it in the wrong place then.. your problem lies in where you have your include file.
Sarah