TEST SITE Look here to see code in action
I have two arrays which when echo'd show exactly what i want it to (look at the test site). I'm trying to get them both into a html table but it is only showing the last entry. I have shoved the entire array code into the table and it works fine (although there all in the same row and not separated) but as it is being used in a html email i'm not sure if this will be safe? I'm sorry if this is a really simple fix i'm new to php/mysql so the simple things seem impossible at the moment. I also know i could no doubt combine the two arrays but im on a KISS mantra at the moment and this is the easiest for me to understand. Any help would be appreciated. Thanks.
<?php
//Get Order Codes
foreach ($ids as $id) {
$sqlcode = "SELECT od_code FROM tbl_order_code WHERE pd_id = $id LIMIT 1";
$result = mysql_query($sqlcode);
while($row = mysql_fetch_assoc($result)) {
$codes['codes'] = $row['od_code'];
}
echo "".$codes['codes']."<br />";
}
//Get Product Name
foreach ($ids as $id) {
$sqlname = "SELECT pd_name FROM tbl_product WHERE pd_id = $id";
$result = mysql_query($sqlname);
while($row = mysql_fetch_assoc($result)) {
$names['names'] = $row['pd_name'];
}
echo "".$names['names']."<br />";
}
?>
<table width='550' border='1' align='center' cellpadding='5' cellspacing='1'>
<tr>
<td>Description</td>
<td>Code</td>
</tr>
<tr>
<td> <?php echo "". $names['names'].":"."<br>"?> </td>
<td> <?php echo "". $codes['codes']."<br>"?> </td>
</tr>
</table>