Is it possible to create variables dynamically in a for each loop?
I want to store data on items in my basket in session variables. The basket items are being displayed on the screen using the for each loop, and I have been trying to create session variables to hold specific data. Here is my code:
You can see that I am needing to create a session variable to hold and store id, quantity and price but for each item in the basket, this can be one or many. Is there a way to create these variables every time another item is run through the for each loop? I need to add the id, quantity and price for each item to an orders table individually as each item gets its own id in the table.
foreach ($basketarray as $value)
echo "<div id='basketitems'><br/>
<img id='searchimage' src=".$value['picture']." width='210' height='250' /><br/>";
$_SESSION['Bprodid'] = $value['id'];
$_SESSION['Bprodquantity'] = $value['quantity'];
$_SESSION['Bprodprice'] = $value['price'];
echo "<form action='deletefrombasket.php' name='basketdelete$items' id='basketdelete$items' method='POST'>
<input type='submit' name='".$value['basketid']."' value='Remove' id='basketid' name='basketid'/>
Any help is appreciated!