How does it fail to work? It's easy to see at a glance that the table code won't work, but how about the data? Is the correct data showing up?
First, let's try cleaning up the code so we can read it, and so that it will at least generate a table:
$display_block .= '<table cellpadding="10" cellspacing="10">';
while ($subcats = mysql_fetch_array($get_subcats_res)) {
$subcats_id = $subcats['id'];
$subcats_title = stripslashes($subcats['subcat_title']);
$get_subcats_count = "select count(subcat_id) as mycount from store_items where subcat_id = ".$subcats_id;
$subcats_count_res = mysql_query($get_subcats_count) or die(mysql_error());
$item_count = mysql_fetch_array($subcats_count_res);
$items_amount = $item_count['mycount'];
$cell = '<td><p><li><strong>';
$cell .= '<a href="seeitemlist.php?subcats_id="' . $subcats_id . '">"';
$cell .= $subcats_title . '</a> ';
$cell .= $items_amount . '</strong></li></p></td>';
if ($subcat_id % 2) {
$display_block .= '<tr>' . $cell;
} else {
$display_block .= $cell . '</tr>';
}
}
$display_block .= '</table>';
Run that and then post any error messages you get, whether the data you expect is being displayed, and whatever specifically is not right.
As for the code you posted--this line:
$display_block .=
"<table cellpadding = \"10\" cellspacing = \"10\">";
can be done with single quotes to get rid of the backslashes (see above).
This:
$display_block .=
"<tr>
<td><p><li><strong><a href='seeitemlist.php?subcats_id=".$subcats_id."'>".$subcats_title."</a> ".$items_amount."</strong></li></p></td>";
is better done with single quotes around the whole thing and double quotes around the html attribute values, as per custom (s.a.).
In this part:
subcats_id=".$subcats_id."'>".$subcats_title."</a>
you have a quote at the end of the subcats_id value, but none before (which would likely screw up the display).
This line:
</tr>";
will of course cause a syntax error, which I imagine is as far as you got because the script would exit.
The modulus 2 expressions can be shortened, since they will be either 0, which resolves to false, or 1, which resolves to true.
Put single quotes around array indexes to avoid collisions with constants.
All that html you have for each "if" can be put into a variable first to keep from entering it twice and, again, to keep the code cleaner and more readable.
(Edited to correct "<tr>" placement.)
(Re-edited because I had it right the first time--I think. :queasy: )