El Forum
08-08-2012, 10:33 AM
[eluser]ppwalks[/eluser]
I am trying to build an array to insert into db, I have a count and want to build the array according to the count so used a for loop, except it is only showing the last result of the array so could someone help with this please.
The ouput to screen is:
( [7] => 126 )
when it should start from 1 and increment to 7 as a for loop should, where am i going wrong
I am trying to build an array to insert into db, I have a count and want to build the array according to the count so used a for loop, except it is only showing the last result of the array so could someone help with this please.
Code:
$count = count($_POST['cat_id']);
for ($i=1; $i<=$count; $i++)
{
$product = array( $i => $prod);
}
The ouput to screen is:
( [7] => 126 )
when it should start from 1 and increment to 7 as a for loop should, where am i going wrong