DarrenReeder Posted December 1, 2009 Share Posted December 1, 2009 in my array that im using to display information, i echo out the info in a while loop but a piece of data (from the start i think) is always missing, how do i get this data to display? here is my code $myname = $_SESSION['username']; $query="select * FROM messages WHERE to_user ='$myname' "; $result=mysql_query($query); while($rows=mysql_fetch_array($result)) { echo "<font color='red'>From:</font> <font color=white>" . $rows['from_user'] . "</font><br>"; echo "<font color='red'>Contents:</font> <font color=white>" . $rows['message_contents'] . "</font><br><br>"; } Link to comment https://forums.phpfreaks.com/topic/183544-array-missing-data/ Share on other sites More sharing options...
trq Posted December 1, 2009 Share Posted December 1, 2009 How many results are you expecting? Nothing in that code would suggest its missing any rows, maybe you simply forgot to echo the field in question? Link to comment https://forums.phpfreaks.com/topic/183544-array-missing-data/#findComment-968784 Share on other sites More sharing options...
DarrenReeder Posted December 1, 2009 Author Share Posted December 1, 2009 Well whatever is first in the array, it doesnt show up on the echo but everything else does Link to comment https://forums.phpfreaks.com/topic/183544-array-missing-data/#findComment-969076 Share on other sites More sharing options...
zeodragonzord Posted December 1, 2009 Share Posted December 1, 2009 Replace your while-loop code with this and see if you actually have data returned from the database. If data you're expecting is not displayed, then check your query. If you have data displayed on the page, then check the name of the fields it shows and see if you happened to misspell your variable names inside the while-loop. while($rows=mysql_fetch_array($result)) { var_dump($rows); } Link to comment https://forums.phpfreaks.com/topic/183544-array-missing-data/#findComment-969093 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.