sono-io@xxxxxxxxxxxxx wrote: > > 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 got the headers to work with this code: > > ... > foreach ( $cats AS $cat ) { > echo '<th align="center">Item ID</th>'; > echo '<th align="center">Description<br />'; > echo '<font size="-1">(Click for more info)</font></th>'; > echo '<th align="center">Price Each</th>'; > echo '<th align="center">Purchase</th>'; > } > echo '</tr><tr>'; > ... > > (I don't need to show the category #'s in the header fields) but I can't > get the rest of the data to flow like I want it. > > Thanks, > Frank > After Thought! I saw your other email before sending. The problem with the way you show you want it there is that each result set would have to be the same size. I'm going to assume that they won't be, so my solution below show take care of it. ... Well, this makes things a little more complicated. But, here is another round... <?php $item_list = ""; $cats = array('01100-01200-01300-06403', '01100-02201-01300-06403'); echo '<table border=1>'; echo '<tr>'; foreach ( $cats AS $cat ) { echo <<<START <td valign="top"> <table border=1> <tr> <th>Item#</th> <th>Description</th> <th>Price</th> </tr> START; $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 <tr> <td>{$item['itemid']}</td> <td>{$item['description']}</td> <td>{$item['price']}</td> </tr> ROW; } } else { echo "No results for category #{$cat}!"; } echo '</table></td>'; } echo '</tr></table>'; ?> I think all the above is correct. Give it a try and let us know. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php