feri_soft Posted January 6, 2007 Share Posted January 6, 2007 How dynamically to generate a table like this:I have 22 subcategories in mysql i open a main category and i want all the subs to be shown in the page but formated as a table, not simple <br>Like;adasd asdasdasd asdasasdasda adasdasdasd asdasdaadasdasd adasdasdasdasd adasdasdI cant figure out a way because the number of subcats for each category is not fixed. And there are categories with only 2-3 subs....Please help! Link to comment https://forums.phpfreaks.com/topic/33116-dynamic-table-generation/ Share on other sites More sharing options...
Hypnos Posted January 6, 2007 Share Posted January 6, 2007 I'm just guessing your table structure here...[code=php:0]echo "<table>";while($row = mysql_fetch_array($result)) {echo "<tr><td>";//If previous cat isn't the same as this one, echo it.if($catcache != $row['cat']) echo $row['cat'];echo "</td><td>";echo $row['subcat'];echo "</td></tr>";$catcache = $row['cat'];}echo "</table>";[/code]If your SQL table isn't setup like I assumed, post an example of it. Link to comment https://forums.phpfreaks.com/topic/33116-dynamic-table-generation/#findComment-154300 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.