Page 1 of 1

Not getting first piece of data in query HELP!!

Posted: Tue Jun 01, 2004 8:45 am
by stantheman
In my while loop it is not getting the first person in the query

here is my connnection string also

Code: Select all

<?php require_once('Connections/mid_state_prd_cat.php'); ?>
<?php
mysql_select_db($database_mid_state_prd_cat, $mid_state_prd_cat);
$query_gaylord = "SELECT location, FirstName, LastName, Title, email FROM location_contacts WHERE location = 'gaylord'";
$gaylord = mysql_query($query_gaylord, $mid_state_prd_cat) or die(mysql_error());
$row_gaylord = mysql_fetch_assoc($gaylord);
$totalRows_gaylord = mysql_num_rows($gaylord);
?>

Code: Select all

while($row_gaylord = mysql_fetch_assoc($gaylord))
		   &#123;      
		
		    echo ("<tr>");
		    echo $row_gaylord&#1111;'FirstName'];
	  	    echo ("</tr>"); 
		   &#125;

Posted: Tue Jun 01, 2004 9:09 am
by Weirdan
It's because you've fetched first row before entering the while loop. Here is where it happened:

Code: Select all

//..............
$gaylord = mysql_query($query_gaylord, $mid_state_prd_cat) or die(mysql_error());
$row_gaylord = mysql_fetch_assoc($gaylord);  // <=================   removing of this string should solve your problem
$totalRows_gaylord = mysql_num_rows($gaylord); 
//.............

Posted: Tue Jun 01, 2004 9:11 am
by JayBird
Nice named variables BTW ;)

Posted: Tue Jun 01, 2004 1:11 pm
by stantheman
Thanks I just overlooked that i should have been thinking