faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

10 of 13 people (77%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

Why is my first record never showing up?

Sep 6th, 2003 01:26
Chukwuma Uzoma-Nze, Delaney Hee Kuan Weng, Kevin Nonya,


your first record never come out??  shouldn't be.  mayb U can check 
the "FOR" statement......
The problem is not the for or while or whatever statement but WHERE you 
put the statement that retrieves the actual data from the database:
This will not get the first row"
********************************************
$query = mysql_query("select bla, bla2, bla3 from BLA",$conn);
$queryArray = mysql_fetch_array($query);
while($queryArray = mysql_fetch_array($query))
{
print "$$queryArray[0]<br>";
print "$$queryArray[1]<br>";
print "$$queryArray[2]<br>";
}
This WILL:
********************************************
$query = mysql_query("select bla, bla2, bla3 from BLA",$conn);
while($queryArray = mysql_fetch_array($query))
{
print "$$queryArray[0]<br>";
print "$$queryArray[1]<br>";
print "$$queryArray[2]<br>";
}
Notice how the first mysql_fetch_array statement is missing? Well, that 
is the cause of the dissappearing row. Each statement of that eats away 
at one row! This is not a bad thing it can be useful when you want to 
display the first row seperatley b4 looping through the rest!
Courtesy The DEBAUN Co. cjunze@hotmail.com