Web Hosting Talk







View Full Version : How to get result into an array


flashwebhost
05-17-2007, 08:49 AM
Hi,

I need to get MySQL query result into array.

mysql_fetch_array can do it, but only for a row. I need entire results into an array.

$myarray = mysql_fetch_array($result);

If i print, i get some thing like below


Array
(
[0] => 1
[id] => 1
[1] => Sports
[name] => Sports
)


This is only for one record, i need to get multiple records in to same array, so i can pass it to smarty template system, that can display the array.

Any suggestions ?

With adodb, there is a function

$myarray = $rs->getarray();

I need exactly same done with mysql basic functions (no adodb).

Thanks,

Yujin

deef
05-17-2007, 09:40 AM
You need the while function, which means that it will display multiple rows out of the MySQL database.

flashwebhost
05-17-2007, 10:08 AM
Thanks deef :)