numtre Posted October 25, 2008 Share Posted October 25, 2008 Hello everyone This is my first post, I'm kind of a php/mysql newbie so i would appreciate any help Here's my simple code: <?php $con = mysql_connect("localhost","inteoria_crash","****"); if (!$con) { die ('Could not connect.'.mysql_error()); } mysql_select_db ("inteoria_vera",$con) or die(mysql_error()); $result=mysql_query("SELECT * FROM tblNews"); $row=mysql_fetch_array($result); echo "<ul>"; while ($row=mysql_fetch_array($result)) { echo "<li><span class='bold'>".$row['date']."</span>: ".$row['content']."</li>"; } echo "</ul>"; mysql_close($con); ?> Now, my question is: If I have four records in my DB: http://img353.imageshack.us/my.php?image=picture2wv0.png Why the hell do I only get to see 3? http://img151.imageshack.us/my.php?image=picture3xr1.png Link to comment https://forums.phpfreaks.com/topic/130054-solved-cant-understand-why-while-loop/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 25, 2008 Share Posted October 25, 2008 Because the following line in your code is fetching the first row from the result set and not using - $row=mysql_fetch_array($result); Why do you have that line of code in your code? Link to comment https://forums.phpfreaks.com/topic/130054-solved-cant-understand-why-while-loop/#findComment-674352 Share on other sites More sharing options...
numtre Posted October 26, 2008 Author Share Posted October 26, 2008 thx for pointing me in the right direction clearly i'm missing some basics i'll be back soon Link to comment https://forums.phpfreaks.com/topic/130054-solved-cant-understand-why-while-loop/#findComment-675152 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.