Jump to content

array missing data...


DarrenReeder

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.