Hi guys I got this problem, at the moment the code below: while ($cats = mysql_fetch_array($get_cats_res)) { $cat_id = $cats[id]; $cat_title = strtoupper(stripslashes($cats[cat_name])); $cat_desc = stripslashes($cats[cat_desc]); $display_block .= "<tr><td width ='300' height ='50'><strong><a href=\"catagories.php?cat_id=$cat_id\">$cat_title</a></strong> $cat_desc</td></tr>"; } displays <tr><td></td></tr> <tr><td></td></tr> <tr><td></td></tr>..... i want it to display like this <tr><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td></tr> <tr><td></td><td></td><td></td></tr>..... where you display only 3 columns in a row Can anyone of you help me with this problem pls...
Change: $display_block .= "<tr><td width ='300' height ='50'><strong><a href=\"catagories.php?cat_id=$cat_id\">$cat_title</a></strong> $cat_desc</td></tr>"; PHP: To: $display_block .= "<tr><td width ='300' height ='50'><strong><a href=\"catagories.php?cat_id=$cat_id\">$cat_title</a></strong> $cat_desc</td><td></td><td></td></tr>"; PHP: Or: $display_block .= "<tr><td width ='300' height ='50' colspan='3'><strong><a href=\"catagories.php?cat_id=$cat_id\">$cat_title</a></strong> $cat_desc</td></tr>"; PHP:
Vbot, I think he wants items in those new cells $i = 0; define('ITEMS_PER_ROW', 3); while ($cats = mysql_fetch_array($get_cats_res)) { $cat_id = $cats[id]; $cat_title = strtoupper(stripslashes($cats[cat_name])); $cat_desc = stripslashes($cats[cat_desc]); if ($i % ITEMS_PER_ROW == 0) $display_block .= '<tr>'; $display_block .= "<td width ='300' height ='50'><strong><a href=\"catagories.php?cat_id=$cat_id\">$cat_title</a></strong> $cat_desc</td>"; if (++$i % ITEMS_PER_ROW == 0) $display_block .= '</tr>'; } PHP:
thanks Guys Vbot that code doesn't do what I want it to do but I appreciate the help. Krt thanks thats brilliant, it works like a bomb, Now why didn't I think of that lol, Thanks again guys...