On Jul 28, 2009, at 12:48 PM, Jim Lucas wrote:
<?php
$item_list = "";
$cats = array('01100-01200-01300-06403', '01100-02201-01300-06403');
echo '<table border="1">';
echo '<tr>';
foreach ( $cats AS $cat ) {
echo '<th>'.htmlspecialchars($cat).'</th>';
}
echo '</tr><tr>';
foreach ( $cats AS $cat ) {
echo '<td>';
$cat = mysql_real_escape_string($cat, $db);
$SQL = "SELECT itemid,description,unitprice
FROM catalog
WHERE categories='$cat'
ORDER BY itemid";
if ( ($result = mysql_query($SQL, $db)) !== false ) {
while ( $item = mysql_fetch_assoc($result) ) {
$price = money_format('%i', $item['unitprice']);
echo <<<ROW
<a href="shop.cgi?c=detail.htm&itemid={$item['itemid']}"
>{$item['description']}</a>
ROW;
}
} else {
echo "No results for category #{$cat}!";
}
echo '</td>';
}
echo '</tr></table>';
?>
We're getting close! This now displays everything in 2 columns.
Ultimately, what I need is a display like this:
Starter Units Add-On Units
Item# Description Price Item# Description Price
18247C4 -------- $85.89 A18247C4 ------- $76.32
18367C4 -------- $97.37 A18367C4 ------- $82.55
I just noticed something. This code places all items in a single
<tr></tr> block. Each item needs to be separated, so using my example
data above the html output would need to look like this:
<tr>
<td colspan="3">Starter Units</td>
<td colspan="3">Add-On Units</td>
</tr>
<tr>
<td>Item#</td>
<td>Description</td>
<td>Price</td>
<td>Item#</td>
<td>Description</td>
<td>Price</td>
</tr>
<tr>
<td>18247C4</td> <-- starter unit info
<td>--------</td> " "
<td>$85.89</td> " "
<td>A18247C4</td> <-- add-on unit info
<td>-------</td> " "
<td>$76.32</td> " "
</tr>
<tr>
<td>18367C4</td> <-- starter unit info
<td>--------</td> " "
<td>$97.37</td> " "
<td>A18367C4</td> <-- add-on unit info
<td>-------</td> " "
<td>$82.55</td> " "
</tr>
Thanks,
Frank
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php