I have no account on dp, and don't want to make another one.
The word NULL means that you have the variable declared, but it's value is bull, not an array, so the foreach cannot iterate through it.
So, for finding where your problem is, go step by step.
First, try to dump $products after the db retrieval:
Code:
$query = "SELECT image_url, description FROM `products` ORDER BY rand() LIMIT 4;";
database_inquiry($query, $rows);
$products = $rows;
Then, as you re-populate it later, try after the update:
PHP Code:
$i=0;
foreach ($products as $item)
{
$item['price'] = '$'.number_format($item['price'],2,'.',',');
$products[$i] = $item;
$i++;
}
I don't see any flagrant errors in your script. Just as a remark, you blindly set $i as the array key. Why not use the extended syntax of foreach, which allow you the get both index and value ?
PHP Code:
foreach ($products as $key=>$item){
$item['price'] = '$'.number_format($item['price'],2,'.',',');
$products[$key] = $item;
}
But your best way to find out what's happen is to deplace the var_dump() block you put after my first post, and see where the content of $products disapears, or if it ever get filled from the db. Maybe database_inquiry() isn't working in that page...