note 96518 deleted from function.mysql-fetch-array by danbrown
| From: | danbrown@php.net | Date: | Wed, 03 Mar 2010 14:33:46 +0000 |
| Subject: | note 96518 deleted from function.mysql-fetch-array by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166562@lists.php.net to get a copy of this message | ||
Note Submitter: Sebastian K
----
Sorry for my last note. A better solution was already posted.
The function also has the ability to return the columns numerically, associatively, or both, just as
mysql_fetch_array() does. It uses MYSQL_NUM, MYSQL_ASSOC, and MYSQL_BOTH (MYSQL_BOTH being the
default).It returns a 2-dimensional array in the form of $arr[number_row_returned][column_desired].
So, if there is some column 'password', and you want the password from the third returned
row:
<?php
$result = mysql_query($query);
$arr = mysql_fetch_rowsarr($result);
$password = $arr[2]['password'];
function mysql_fetch_rowsarr($result, numass=MYSQL_BOTH{
$got=array();
mysql_data_seek($result, 0);
while ($row = mysql_fetch_array($result, $numass)) {
array_push($got, $row);
}
return $got;
}
?>
see:
joaocosta at zonalivre dot org
22-Jul-2007 02:29
and
devinivy at gmail dot com
16-Jul-2007 04:02