raphael1 Posted November 23, 2010 Share Posted November 23, 2010 For some reason my php script only echo's out one data, I can't seem to find the problem. <? $show = mysql_query("SELECT * FROM video_comments WHERE pageid='$vidid'"); $numrows = mysql_num_rows($show); if ($numrows > 0){ while($row = mysql_fetch_array($show)){ $userid = $row["userid"]; $username = $row["username"]; $comment = $row["comment"]; $date = $row["date"]; $date = strftime("%b %d, %Y", strtotime($date)); } echo" <table style='background-color:#FFF; border:#999 1px solid; border-top:none;' cellpadding='5' width='100%'> <tr> <td width='90%' valign='top' style='line-height:1.5em;'><span class='greenColor textsize10'>$date<a href='profile.php?id=$userid'> $username </a> said:</span><br /> $comment</td> </tr> </tr></table> "; } else echo"<center><font face='arial' size='2'><p>This video has no comments.</font></center>"; ?> Quote Link to comment Share on other sites More sharing options...
New Coder Posted November 23, 2010 Share Posted November 23, 2010 You need to put the echo detail within the while loop otherwise I'm assuming it's only echoing the last record found or rarther than build the table every time you could just add to it like: <? $show = mysql_query("SELECT * FROM video_comments WHERE pageid='$vidid'"); $numrows = mysql_num_rows($show); if ($numrows > 0) { $list = "<table style='background-color:#FFF; border:#999 1px solid; border-top:none;' cellpadding='5' width='100%'>"; while($row = mysql_fetch_array($show)) { $userid = $row["userid"]; $username = $row["username"]; $comment = $row["comment"]; $date = $row["date"]; $date = strftime("%b %d, %Y", strtotime($date)); $list .= "<tr>"; $list .= "<td width='90%' valign='top' style='line-height:1.5em;'><span class='greenColor textsize10'>$date<a href='profile.php?id=$userid'> $username </a> said:</span><br /> $comment</td>"; $list .= "</tr>"; } $list .= "<table>"; echo ( $list ); } else { echo"<center><font face='arial' size='2'><p>This video has no comments.</font></center>"; } ?> Code not tested but should give you an idea Quote Link to comment Share on other sites More sharing options...
MrXHellboy Posted November 23, 2010 Share Posted November 23, 2010 Confirm that. The last result will be stored! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.