phpstuck Posted February 7, 2010 Share Posted February 7, 2010 Ok here's my problem. I am running an inventory database (MySQL) using PHP to generate several different reports. I have a row in my table named CAT, I would like to generate a report using the CAT as a header. It would pull a CAT name from the table, echo it as a header and then list each item with that particular CAT name. making it look like this: Canned Food: Kroger, Sweet Corn 11 Cans Kroger, Early Peas 13 Cans etc... Boxed Food: Kraft, Mac & Cheese 24 Boxes Kroger, Saltine Crackers 8 boxes etc... Where as canned foods and boxed foods are CAT (category) entries from the database. I have tried using the following code, but it falls very short. $sql = mysql_query( "ALTER TABLE inven ORDER BY cat"); echo "<br><hr>"; $deflist=mysql_query( "SELECT quant, brand, descrip, size, flavor, cat FROM inven"); while ($all = mysql_fetch_array($deflist)) { $quant=$all['quant']; $brand=$all['brand']; $descrip=$all['descrip']; $size=$all['size']; $flavor=$all['flavor']; $cat=$all['cat']; //{ echo "<p>".$cat."</p>"; } //echo "<b><font face='arial' size='2'><u>(".$quant. //") </b></font></u><font face='arial' size='2'>".$brand.", ". //" - "."<font color='grey' size='-1'><i>".$descrip." - ".$flavor. //"</i></font> - <i><font color='purple' size='-3'></i>".$size. //"</font><br>"; //} ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.