user1506375 user1506375 - 3 years ago 58
HTML Question

html php printing error

I have the following script which is an order list:

<?php
$manifest_query = tep_db_query("SELECT o.franchise_id, o.orders_id,
o.customers_id, o.delivery_name, o.delivery_street_address [...]");
while ($manifest = tep_db_fetch_array($manifest_query)){
?>
<tr>
<td height="50" align="center"><?php echo $manifest['orders_id'] ;?></td>
<td cellpadding="2"><?php echo $manifest['delivery_name'] .'<br> '.
$manifest['delivery_street_address'] .'<br> '.
$manifest['delivery_city'].'<br> '.
$manifest['delivery_postcode'].'<br> '.
$manifest['delivery_state'].'<br> '. $manifest['customers_telephone'] ;?>
</td>

<?php
$products_query = tep_db_query("select products_model, products_name, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$manifest['orders_id'] . "'");
while ($products = tep_db_fetch_array($products_query)) {
?>

<td><?php echo$products['products_quantity'] . '&nbsp;x&nbsp;' . $products['products_name'] .
'<br> ' . '&nbsp;&nbsp;'.$products['products_model'] .'<br>';?></td>
<?php
}
?>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td colspan="2"></td>
</tr>

<?php
}
?>


The cell that prints the
$products
variable repeats each time, as a new td, but if there is more than one product I need it to print all the products in one td. Am I in a bit of a muddle?

Answer Source

You have the <td> tags inside your loop. Move them outside the loop, so you don't produce a new cell for each product.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download