a1amattyj Posted May 25, 2008 Share Posted May 25, 2008 Hello, Function: function News() { mysql_close($conn2); require ('multi_operations/config_inc.php'); $query = "SELECT * FROM multi_news ORDER BY id DESC"; $result = mysql_query($query) or die(mysql_error()); $row2 = mysql_fetch_array($result); if ($row2['status'] == '1') { while($row2 = mysql_fetch_array($result)){ echo ' <table width="100%" cellpadding="3" cellspacing="1" border="0" class="bordercolor"> <tr class="titlebg"> <td align="center" colspan="2" class="largetext"><b>'.$row2['subject'].' - '.$row2['date'].'</b></td> </tr> <tr> <td class="windowbg" valign="top" style="padding: 7px;"> <div style="font-size: 0.85em">'.$row2['message'].'</div> </td> </tr> </table> '; } } mysql_close($conn); } However, with the select mysql ^ if there is one result in the database, it will not display it. If there is a second result in the database, it will display the first one. if i insert a third result, it will show the last two but not the most recent one. So basically, it is not displaying the most recent one. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/107224-function-not-showing-all-results/ Share on other sites More sharing options...
DeanWhitehouse Posted May 25, 2008 Share Posted May 25, 2008 try chaging if ($row2['status'] > 0) { Quote Link to comment https://forums.phpfreaks.com/topic/107224-function-not-showing-all-results/#findComment-549730 Share on other sites More sharing options...
a1amattyj Posted May 25, 2008 Author Share Posted May 25, 2008 Nope, still does the same. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/107224-function-not-showing-all-results/#findComment-549731 Share on other sites More sharing options...
sasa Posted May 25, 2008 Share Posted May 25, 2008 function News() { mysql_close($conn2); require ('multi_operations/config_inc.php'); $query = "SELECT * FROM multi_news WHERE `status`='1' ORDER BY id DESC"; $result = mysql_query($query) or die(mysql_error()); // $row2 = mysql_fetch_array($result); // if ($row2['status'] == '1') { while($row2 = mysql_fetch_array($result)){ echo ' <table width="100%" cellpadding="3" cellspacing="1" border="0" class="bordercolor"> <tr class="titlebg"> <td align="center" colspan="2" class="largetext"><b>'.$row2['subject'].' - '.$row2['date'].'</b></td> </tr> <tr> <td class="windowbg" valign="top" style="padding: 7px;"> <div style="font-size: 0.85em">'.$row2['message'].'</div> </td> </tr> </table> '; } // } mysql_close($conn); } Quote Link to comment https://forums.phpfreaks.com/topic/107224-function-not-showing-all-results/#findComment-549743 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.