Page 1 of 1

missing data from mysql...

Posted: Sat Apr 24, 2010 11:55 pm
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....

Re: missing data from mysql...

Posted: Sun Apr 25, 2010 12:31 am
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

Re: missing data from mysql...

Posted: Sun Apr 25, 2010 2:54 am
by GodSINt
Thank You I have been stumped with this for weeks. The do-while fixed it right up!

Re: missing data from mysql...

Posted: Sun Apr 25, 2010 2:57 am
by Gustava
Anytime