missing data from mysql...

Post all your tuts or request for tuts here.
Post Reply
User avatar
GodSINt
Posts: 8
Joined: Thu Apr 01, 2010 4:41 am

missing data from mysql...

Post by GodSINt »

Everytime I try to output things in a table from mysql, the first item is never displayed..... For example if I try to make a memberslist, just a basic list of names, and the first person's name is Joe the second is james and so forth. It completely skips Joe and starts with james.....

here is basicly what I'm doing. I know I don't need to get all from the database to display just the name but thats irrelevant..

Code: Select all

///get the members info///
$memberinfo = "SELECT * from users ORDER BY id";
$memberinfo2 = mysql_query($memberinfo) or die("Could Not Get Memberinfo!");
$memberinfo3 = mysql_fetch_array($memberinfo2);

$name = $memberinfo3['name'];

////output into a table.. table borders and such are in a css file.../////
print "<center>";
print "<table>";
print "<tr><td>Members</td></tr>";

///while isn't needed in this example, but I put it anyways////
while($memberinfo3=mysql_fetch_array($memberinfo2))
{
  print "<tr><td>$name</td></tr>";
}
print "</table>";
print "</center>";
This is just a basic example, but the problem persists throughout anything I try to put into a table, like inventory or store items....
Image
Gustava
Posts: 66
Joined: Tue Dec 29, 2009 5:49 am

Re: missing data from mysql...

Post by Gustava »

Code: Select all

$memberinfo3 = mysql_fetch_array($memberinfo2);
This fetches the first row, and the loop continues from the second. If you need this line there, then use a do-while loop.

http://us2.php.net/control-structures.do.while
User avatar
GodSINt
Posts: 8
Joined: Thu Apr 01, 2010 4:41 am

Re: missing data from mysql...

Post by GodSINt »

Thank You I have been stumped with this for weeks. The do-while fixed it right up!
Image
Gustava
Posts: 66
Joined: Tue Dec 29, 2009 5:49 am

Re: missing data from mysql...

Post by Gustava »

Anytime
Post Reply

Return to “Tutorials”