Not getting first piece of data in query HELP!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stantheman
Forum Commoner
Posts: 38
Joined: Wed May 26, 2004 8:57 am

Not getting first piece of data in query HELP!!

Post 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;
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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); 
//.............
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Nice named variables BTW ;)
stantheman
Forum Commoner
Posts: 38
Joined: Wed May 26, 2004 8:57 am

Post by stantheman »

Thanks I just overlooked that i should have been thinking
Post Reply