Xyphon Posted December 15, 2007 Share Posted December 15, 2007 <?PHP include('Connect.php'); include('top.php'); $result = mysql_query("SELECT * FROM news_comments ORDER BY id_comment DESC"); echo "<table border='1' bgcolor='lightgrey'> <tr> <th>Hi,<br /> It's Xyphon. I have just made the news page, I hope you like it! Please, leave comments here!</th> </tr></table>"; echo "<table border='1' width='500' bgcolor='lightgrey'>"; echo "<tr> <td> <a href='postcomment.php'>Post Comment</a></td>"; echo "<td> <a href='viewcomments.php'>View Comments</a></td></tr></table>"; if(!$row = mysql_fetch_array($result)){ echo "There are no current comments."; } else { while($row = mysql_fetch_array($result)){ echo "<table border='1' width='500' height='20' bgcolor='lightgrey'>"; echo "<br /><br />"; echo "<tr>"; echo "<td><center><b>Username: </b><br />" . $row['username'] . "</center></td>"; echo "<td><center><b>ID: </b><br />" . $row['user_id'] . "</center></td></tr></table>"; echo "<table border='1' width='500' height='20' bgcolor='lightgrey'><tr><td><b>Comment:</b>"; echo "<td>" . $row['comment'] . "</td>"; echo "</tr></table>"; } } include('bottom.php'); ?> The last comment made wont show until a new comment is posted.. Why? Link to comment https://forums.phpfreaks.com/topic/81804-solved-weird-problem/ Share on other sites More sharing options...
kenrbnsn Posted December 15, 2007 Share Posted December 15, 2007 You are retrieving the first comment here: <?php if(!$row = mysql_fetch_array($result)){ echo "There are no current comments."; } else { ?> but not doing anything with it. You should use the following instead: <?php if(mysql_num_rows($result) == 0) echo "There are no current comments."; else { while($row = mysql_fetch_array($result)){ ?> Ken Link to comment https://forums.phpfreaks.com/topic/81804-solved-weird-problem/#findComment-415609 Share on other sites More sharing options...
Xyphon Posted December 15, 2007 Author Share Posted December 15, 2007 Thank you, it's fixed ken. Link to comment https://forums.phpfreaks.com/topic/81804-solved-weird-problem/#findComment-415611 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.