brem13 Posted August 30, 2009 Share Posted August 30, 2009 ive got a menu in a mysql database and there are different things like salads, sandwiches, etc. in the database i have the fields contain the entree, price and the type(salad, sandwich, etc). i want the type(Salad) to be a header for all 5 salads but it shows up for every salad, see screenie below. basically, i want it to show 'salads' as a header above all the salads. how can i get it to not show salads for the other 4 salads. my code is $result = mysql_db_query('btscrows_menu', "select * from lunch") or die (mysql_error()); while($qry = mysql_fetch_array($result)){ $entree = $qry['entree']; $desc = $qry['desc']; $price = $qry['price']; $type = $qry['type']; echo '<tr>'; echo '<td align=center colspan=5><font face=tahoma size=3><i><b>'.$type.'</b></i></font></td>'; echo '</tr>'; echo '<tr>'; echo '<td width=100px></td>'; echo '<td width=200px><font face=tahoma size=2><strong>'.$entree.'</strong></font></td>'; echo '<td width=300px><font face=tahoma size=2>'.$desc.'</font></td>'; echo '<td width=100px><font face=tahoma size=2>$'.$price.'</font></td>'; echo '<td width=35px></td>'; echo '</tr>'; [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/172436-solved-multiple-of-same-field/ Share on other sites More sharing options...
brem13 Posted August 30, 2009 Author Share Posted August 30, 2009 fixed it, just added if($type1 != $type){ echo '<td align=center colspan=5><font face=tahoma size=3><i><b>'.$type.'</b></i></font></td>'; $type1=$type; } Link to comment https://forums.phpfreaks.com/topic/172436-solved-multiple-of-same-field/#findComment-909106 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.