Jason Jason - 3 months ago 15
SQL Question

Storing data from SQL in array

I am trying to store the data from my sql database into an array. Currently I have this:

$query = mysql_query("SELECT * FROM `InspEmail` WHERE `Company` LIKE '$company'");

while($row = mysql_fetch_array($query))

$inspector = $row['name'];


The problem is that I have 8 rows of data. I need to store each 8 names from that database into an array. When I try this:

$inspector = array($row['name']);

It doesn't work.


What you want is:

$inspector[] = $row['name'];

This will store all 8 names in an array similar to:

     [0] => name1
     [1] => name2
     [2] => name3