I first off want to thank anyone that can assist me with this.
I have 2 arrays from a database that I am trying to display together in a single foreach statement.
Here are the Arrays:
First Array contains the ID's of the Dishes - MySql Table "tmp_orders['dishes']"
Second Array contains the Additional Quantities of each dish - MySql Table "tmp_orders['additional_dishes']"
Both Items are Serialized and Unserialized to get the Array Below:
Array ( [0] => Array ( [0] => Array ( [0] => 18 [1] => 28 [2] => 48 [3] => 39 [4] => 46 [5] => 52 [6] => 71 [7] => 56 ) ) )
Array ( [0] => Array ( [0] => Array ( [0] => 3 [1] => 5 [2] => 3 [3] => 5 [4] => 3 [5] => 5 [6] => 3 [7] => 5 ) ) )
The Objective:
$dishs=unserialize($cinfo['dishes']);
$extras=unserialize($cinfo['additional_dishes']);
$dis = (array($dishs));
$ext = (array($extras));
foreach ($dis as $i){
foreach ($ext as $v){
$query="SELECT * FROM dishes WHERE id='".$i."'";
$value=mysql_query($query)or die(mysql_error());
while($dishinfo=mysql_fetch_array($value))
{
<tr>
<td class="paymentText2-2"><?php echo $dishinfo['name']; ?></td>
<td class="paymentText2">1 + <?php echo $v; ?> </td>
<?php $ext_total= $v * $dishinfo['price']; ?>
<td class="paymentText2">SGD <?php echo $ext_total; ?> </td>
</tr>
}
}
}
The above code only prints array 1 time for each item. The array seems to be to buried and the only way I have even came close to it working was to do 4 foreach statement like below but it causes to many duplicates.
foreach ($dis as $i){
foreach($i as $e){
foreach ($ext as $v){
foreach ($v as $r){
}}}}