note 30547 added to function.mysql-data-seek
| From: | shawn dot carnley at usm dot edu | Date: | Fri, 21 Mar 2003 16:59:00 +0000 |
| Subject: | note 30547 added to function.mysql-data-seek | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45612@lists.php.net to get a copy of this message | ||
Consider this code....And imagine the DB contains 3 records:
degree, description:
None, None
Art, Art
CSC, CSC
This first time it runs I get:
None - None
Art - Art
CSC - CSC
The second do-while gives:
-
None - None
Art - Art
CSC - CSC
Where is this extra result before "None - None" coming from?
php version 4.1.2
MySQL version 11.18 Distrib 3.23.54, for pc-linux (i686)
<?php
$hostname_Application = "localhost";
$database_Application = "someDB";
$username_Application = "someUserName";
$password_Application = "somePassword";
$Application = mysql_pconnect($hostname_Application, $username_Application, $password_Application)
or die(mysql_error());
mysql_select_db($database_Application, $Application);
$query_Degrees = "SELECT degree, description FROM all_degrees";
$Degrees = mysql_query($query_Degrees, $Application) or die(mysql_error());
$row_Degrees = mysql_fetch_assoc($Degrees);
$totalRows_Degrees = mysql_num_rows($Degrees);
do{
echo $row_Degrees['degree']." -
".$row_Degrees['description']."\n";
}while ($row_Degrees = mysql_fetch_assoc($Degrees));
$rows = mysql_num_rows($Degrees);
if($rows > 0) {
mysql_data_seek($Degrees, 0);
}
echo "\n****************************\n";
do{
echo $row_Degrees['degree']." -
".$row_Degrees['description']."\n";
}while ($row_Degrees = mysql_fetch_assoc($Degrees));
$rows = mysql_num_rows($Degrees);
if($rows > 0) {
mysql_data_seek($Degrees, 0);
}
?>
--
http://www.php.net/manual/en/function.mysql-data-seek.php
http://master.php.net/manage/user-notes.php?action=edit+30547
http://master.php.net/manage/user-notes.php?action=delete+30547
http://master.php.net/manage/user-notes.php?action=reject+30547