note 48764 added to function.mysql-fetch-array
| From: | himself at zhwau dot net | Date: | Thu, 06 Jan 2005 15:10:06 +0000 |
| Subject: | note 48764 added to function.mysql-fetch-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-82841@lists.php.net to get a copy of this message | ||
Browsing through the documentation I noticed there isn't a function to return the whole of the
table when you query a MySQL database. Therefore, i added a function to address this redundancy:
<?php
function mysql_table($query, $db) {
$a = mysql_query($query, $db);
$c = array();
while($b = mysql_fetch_row($a)) {
$c[] = $b;
}
return $c;
}
?>
This function usually takes a SELECT query and returns a multidimensional array, its first dimension
being the row number of the result and the second dimension the associated values of the queried
table.
Hope this helps anyone else too.
----
Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-array.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+48764
Delete -- http://master.php.net/manage/user-notes.php?action=delete+48764&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48764&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48764&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48764&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48764&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48764&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+48764&report=yes
Search -- http://master.php.net/manage/user-notes.php