htmlstig Posted January 31, 2009 Share Posted January 31, 2009 hi all sorry if this is in wrong place. i am making a simple knowledge base script and i have basicly got it working how i want it im just trying to make it "look" better now. on the main kb page i have a list of all categories with a little sub title underneath them, i have them going down in a list. does anyone know how i could get it to show in 2 collums? this is the code im using at the moment <?php include "admin/config.php"; $result = mysql_query("SELECT * FROM faqcategories ORDER BY category") or die(mysql_error()); while ($row = mysql_fetch_array($result)) { print "<tr> <td width=\"30\" valign=\"middle\"><img src=\"images/notepad.png\" width=\"23\" height=\"18\" /></td> <td valign=\"bottom\"><li class=\"category\"><strong><a href=\"sub.php?category_id=$row[id]&cat_name=$row[category]\">$row[category]</a></strong><br><span class=\"sub\">$row[sub]</span></li></td> </tr>"; } mysql_close($link); ?> the admin/config.php has the connections to mysql so they arnt needed in the code. cheers Link to comment https://forums.phpfreaks.com/topic/143210-solved-show-results-in-2-collums/ Share on other sites More sharing options...
landavia Posted January 31, 2009 Share Posted January 31, 2009 using if will be better hmm.. i take from while ($row = mysql_fetch_array($result)) { print "<tr> <td width=\"30\" valign=\"middle\"><img src=\"images/notepad.png\" width=\"23\" height=\"18\" /></td> <td valign=\"bottom\"><li class=\"category\"><strong><a href=\"sub.php?category_id=$row[id]&cat_name=$row[category]\">$row[category]</a></strong><br><span class=\"sub\">$row[sub]</span></li></td> </tr>"; } <?php $i=0; print "<tr>"; while ($row = mysql_fetch_array($result)) { print "\n<td width=\"30\" valign=\"middle\"><img src=\"images/notepad.png\" width=\"23\" height=\"18\" /></td> <td valign=\"bottom\"><li class=\"category\"><strong><a href=\"sub.php?category_id=$row[id]&cat_name=$row[category]\">$row[category]</a></strong><br><span class=\"sub\">$row[sub]</span></li></td>"; $i++; if($i%2==0) print "</tr><tr>"; } print '</tr>'; ?> Link to comment https://forums.phpfreaks.com/topic/143210-solved-show-results-in-2-collums/#findComment-751067 Share on other sites More sharing options...
htmlstig Posted January 31, 2009 Author Share Posted January 31, 2009 many thanks that works great Link to comment https://forums.phpfreaks.com/topic/143210-solved-show-results-in-2-collums/#findComment-751280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.