[PHP] 'while' not picking up on first DB record

2003-09-17 Thread Roger Spears
Hello,

Can anyone from the lists please tell me why this bit of code is not 
picking up on the first record in the database?  If the 'id' I'm looking 
for is '1' it doesn't populate the _SESSION variables.  Any 'id' greater 
then '1' will populate the _SESSION variables.

$q = SELECT * FROM employee;
$r = mysql_query($q);
$row = mysql_fetch_array($r);
while ($row = mysql_fetch_array($r))
 {
   if ($employee == $row[id])
   {
   $_SESSION['dear'] = $row[last_name];
   $_SESSION['to_email'] = $row[email];
   }
 }
Thanks,
Roger
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] 'while' not picking up on first DB record

2003-09-17 Thread Miles Thompson
Please don't cross-post.
See below - M.
At 10:17 AM 9/17/2003 -0400, Roger Spears wrote:
Hello,

Can anyone from the lists please tell me why this bit of code is not 
picking up on the first record in the database?  If the 'id' I'm looking 
for is '1' it doesn't populate the _SESSION variables.  Any 'id' greater 
then '1' will populate the _SESSION variables.

$q = SELECT * FROM employee;
$r = mysql_query($q);
You're picking up first line here, but doing nothing with it.

$row = mysql_fetch_array($r);
So delete it or comment it out.


while ($row = mysql_fetch_array($r))
 {
   if ($employee == $row[id])
   {
   $_SESSION['dear'] = $row[last_name];
   $_SESSION['to_email'] = $row[email];
   }
 }
Thanks,
Roger
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php