Function for putting all database to an array
Posted
by jasmine
on Stack Overflow
See other posts from Stack Overflow
or by jasmine
Published on 2010-03-18T23:50:56Z
Indexed on
2010/03/18
23:51 UTC
Read the original article
Hit count: 432
I have written a function to print database to an array like this
Array(
ID=>1,
PARENTID =>1,
TITLE => LIPSUM,
TEXT =>LIPSUM
)
My function is:
function dbToArray($db)
{
$allArrays =array();
$query = mysql_query("SELECT * FROM $db");
$dbRow = mysql_fetch_array($query);
for ($i=0; $i<count($dbRow) ; $i++)
{
$allArrays[$i] = $dbRow;
}
$txt .='<pre>';
$txt .= print_r($allArrays);
$txt .= '</pre>';
return $txt;
}
Anything wrong in my function. Any help is appreciated about my problem. Thanks in advance
© Stack Overflow or respective owner