Page 1 of 1

How to get all rows in an array

Posted: Sun Sep 20, 2009 6:53 am
by m2babaey
Hi
I want to get table records all in 1 array. I used mysql_fetch_array() but it was returing the first record only
How can all records be stored in 1 array?
I have table: symbols1 and symbols2; I want to get all of their data and then use array_merge() to combine the data
Thanks for your help

Re: How to get all rows in an array

Posted: Mon Sep 21, 2009 6:48 am
by robnet
mysql_fetch_array() will return one row as an array. The next time you call mysql_fetch_array() it will load the second row and so on until there are no more rows in the result set.

Use this:

Code: Select all

<?php
while ($row=mysql_fetch_array($result)){
 // do stuff with new array: $row
}
?>
Within the while loop you can merge your rows or whatever you like.