Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

first row of query not displaing 1

Status
Not open for further replies.

Aeros

Programmer
Joined
Oct 7, 2002
Messages
166
Location
US
Im still new to php and fumbling my way through. I am running the output of a query and the first row is not displaying. This is happening on all my queries. Heres my query and loop im running:

<?php
mysql_select_db($database_todaysmother, $todaysmother);
$query_SelectCats = &quot;SELECT intProdGroupID, varProdGroupName FROM ProductGroup ORDER BY varProdGroupName ASC&quot;;
$SelectCats = mysql_query($query_SelectCats, $todaysmother) or die(mysql_error());
$row_SelectCats = mysql_fetch_assoc($SelectCats);
$totalRows_SelectCats = mysql_num_rows($SelectCats);
?>

<?php
while(list($intProdGroupID,$varProdGroupName) = mysql_fetch_row($SelectCats)){
echo &quot;<option value=$intProdGroupID>$varProdGroupName</option>\n&quot;;
}
?>

TIY
 
It's the spurious fetch operation in this line:

$row_SelectCats = mysql_fetch_assoc($SelectCats);


The basic order of operations is:[ol][li]Fetch a row[/li][li]Output a row[/li][li]Repeat from step one until you run out of rows.[/li][/ol]

Your code, however, performs the following:[ol][li]Fetch a row, then discard that information[/li][li]Fetch a row[/li][li]Output a root[/li][li]Repeat from step 2 until you run out of rows.[/li][/ol]

Thus it should not be suprising that you never get to see the first row of data.

Dump the line I've listed above. You don't in any way need it.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Thanks for the tip...after playing with this for a bit I just figured this part out. Im using dreamweaver mx and it tossed this in.

Thanks again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top