...

View Full Version : creating an array from database data



smeshy123
07-12-2005, 12:50 AM
I am trying to run a mysql_query and return all the results which match the criteria, and then create an array with that data. Any ideas of the best way to do this?

I was using mysql_fetch_assoc(); but then I realized that this function only returns a single result at a time. Are there any functions that will return all the results into an array? Or another way to solve my problem?

Thanks!

Smesh

devinemke
07-12-2005, 01:02 AM
$result = mysql_query('SELECT * FROM table') or exit(mysql_error());
while ($row = mysql_fetch_assoc($result)) {$array[] = $row;}

print_r($array);

smeshy123
07-12-2005, 01:10 AM
Thanks!

Works perfectly :)

Smesh

Nightfire
07-12-2005, 03:04 AM
Use mysql_fetch_array($result)?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum