note 30547 rejected from function.mysql-data-seek by didou
| From: | didou@php.net | Date: | Sat, 17 May 2003 19:43:21 +0000 |
| Subject: | note 30547 rejected from function.mysql-data-seek by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-48222@lists.php.net to get a copy of this message | ||
Note Submitter: shawn.carnley@usm.edu
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);
}
?>