I have been bashing my head against a brick wall with this one.
What I am attempting to do is read a table from mysql database.
From the table I wish to extract the id value and use it as my associative array key and pull the quantity in as the value in the array.
Here is the code I am using:
Code: Select all
<?
//$stock_array = array();
$stock_control = mysql_query ("SELECT * FROM stock_tab WHERE location='mail_order'");
while ($stock_row = mysql_fetch_array($stock_control))
{
$stock_id33 = $stock_row['order_id'];
$qu33 = $stock_row['quantity'];
array_push($stock_array[$stock_id33], $qu33);
}
foreach ($stock_array as $key => $value)
echo $key.'=>'.$value.'<br />';
?>Warning: First argument to array_push() needs to be an array in /data/html/test_site/get_stock_array.php on line 17
so it would appear to be a error in my construction of array_push.
I have used several other methods all of which do not appear to work.
Does anyone know how to correctly code this so that I can push key values and values into my associative array.
Thanks in advance.