note 31873 added to function.mysql-fetch-array
| From: | LouisGreen at pljg dot freeserve dot co dot uk | Date: | Wed, 07 May 2003 17:41:37 +0000 |
| Subject: | note 31873 added to function.mysql-fetch-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47629@lists.php.net to get a copy of this message | ||
While trying out the different versions of mysql_fetch_****(), I discovered, you can only access a
mysql_fetch function once with each query. Here is an example:
$sql_table = "atable";
$sql_where = 908;
$sql_select = "SELECT * FROM $sql_table WHERE field_id ='$sql_where'";
$sql_query = mysql_query($sql_select, $sql_connection);
function fn_one($db_query) {
while($sql_fetch = mysql_fetch_object($db_query)) {
echo $sql_fetch->field_id."< BR >\n";
}
unset($sql_fetch);
}
function fn_two($db_query) {
while($sql_fetch = mysql_fetch_array($db_query)) {
echo $sql_fetch['field_id']."< BR >\n";
}
unset($sql_fetch);
}
------------------------------------------------------
fn_one($sql_query);
echo "<HR>";
fn_two($sql_query);
Note: If you try to use the same query again on a mysql_fetch function, it will not work.
--
http://www.php.net/manual/en/function.mysql-fetch-array.php
http://master.php.net/manage/user-notes.php?action=edit+31873
http://master.php.net/manage/user-notes.php?action=delete+31873
http://master.php.net/manage/user-notes.php?action=reject+31873