Jump to content

[SOLVED] show results in 2 collums


htmlstig

Recommended Posts

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

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>';
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.