I'm doing the following to try to display queried data into verticle
columns, and I'm getting odd behaviors.
For example, if there are only 4 items to display, it skips item number 3:
Item1 Item4
Item 2
If there are 10 items, it duplicates some:
Item 1 Item 4 Item 7
Item 2 Item 5 Item 8
Item 3 Item 6 Item 9
Item 4 Item 7 Item 10
Any help with what I'm doing wrong, I would really appreciate!!
Thanks
$sql_cats = "SELECT * FROM tbl_subcategory WHERE sct_category =
'$proto_cat'";
$result_cats = @mysql_query($s ql_cats, $dbh);
$numrows_cats = mysql_num_rows( $result_cats);
while ($row_cats = mysql_fetch_arr ay($result_cats )) {
$sct_id = $row_cats[sct_id];
$sct_name = $row_cats[sct_name];
$sct_tempdisp .= "<a href=\"category .php?disp=2&cat _id=".$sct_id." \"
class=\"tah12Or angeBold\">".$s ct_name."</a><br /><br />|";
}
$sct_display_X = explode("|", $sct_tempdisp);
$items = $sct_display_X;
For($i = 0; $i< (count($items)/3); $i +=1){
$cat_listx .= "<tr><td width=\"33%\">" .$items[$i]."</td><td
width=\"33%\">" .$items[$i+3]."</td><td>".$items[$i+6]."</td></tr>";
}
$cat_list = "<table width=\"100%\"> ".$cat_list x."</table>";
columns, and I'm getting odd behaviors.
For example, if there are only 4 items to display, it skips item number 3:
Item1 Item4
Item 2
If there are 10 items, it duplicates some:
Item 1 Item 4 Item 7
Item 2 Item 5 Item 8
Item 3 Item 6 Item 9
Item 4 Item 7 Item 10
Any help with what I'm doing wrong, I would really appreciate!!
Thanks
$sql_cats = "SELECT * FROM tbl_subcategory WHERE sct_category =
'$proto_cat'";
$result_cats = @mysql_query($s ql_cats, $dbh);
$numrows_cats = mysql_num_rows( $result_cats);
while ($row_cats = mysql_fetch_arr ay($result_cats )) {
$sct_id = $row_cats[sct_id];
$sct_name = $row_cats[sct_name];
$sct_tempdisp .= "<a href=\"category .php?disp=2&cat _id=".$sct_id." \"
class=\"tah12Or angeBold\">".$s ct_name."</a><br /><br />|";
}
$sct_display_X = explode("|", $sct_tempdisp);
$items = $sct_display_X;
For($i = 0; $i< (count($items)/3); $i +=1){
$cat_listx .= "<tr><td width=\"33%\">" .$items[$i]."</td><td
width=\"33%\">" .$items[$i+3]."</td><td>".$items[$i+6]."</td></tr>";
}
$cat_list = "<table width=\"100%\"> ".$cat_list x."</table>";
Comment