note 96518 added to function.mysql-fetch-array
| From: | SebastianK at osu1 dot php dot net | Date: | Wed, 03 Mar 2010 14:04:39 +0000 |
| Subject: | note 96518 added to function.mysql-fetch-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-166558@lists.php.net to get a copy of this message | ||
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
----
Server IP: 85.214.154.209
Probable Submitter: 89.245.93.247
----
Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-array.php
Edit -- https://master.php.net/note/edit/96518
Del: integrated -- https://master.php.net/note/delete/96518/integrated
Del: useless -- https://master.php.net/note/delete/96518/useless
Del: bad code -- https://master.php.net/note/delete/96518/bad+code
Del: spam -- https://master.php.net/note/delete/96518/spam
Del: non-english -- https://master.php.net/note/delete/96518/non-english
Del: in docs -- https://master.php.net/note/delete/96518/in+docs
Del: other reasons-- https://master.php.net/note/delete/96518
Reject -- https://master.php.net/note/reject/96518
Search -- https://master.php.net/manage/user-notes.php