I am trying to use a foreach loop to set value to populate a table, for some reason my array is showing null inside values. But when I var dump the $result_list[] it shows the array of products, Am i doing this wrong? Thanks
$result = mysql_query("SELECT id, product, price FROM products");
$result_list = array();
while($row = mysql_fetch_array($result)) {
$result_list[] = $row;
}
foreach($result_list as $row) {
$productitems[] = array(
'id' => $row->id,
'product' => $row->product,
'price' => $row->price
);
}
var_dump($productitems);
array(2) { [0]=> array(3) { ["id"]=> NULL ["product"]=> NULL ["price"]=> NULL } [1]=> array(3) { ["id"]=> NULL ["product"]=> NULL ["price"]=> NULL } }