I'm working on building myself an image gallery to store my graphics. I'm starting to get there :) But I've run across one slight problem....
When I click on the category to view the subcat, it doesn't show *all* of the subcats... It cuts off 1 - 3 of them. I can't find any sort of pattern with this, and I double checked my table to make sure that their cat_id was set properly...
Here is my code:
--------------------------
--------
require "database.php";
$title = "Live Journal Icons - $catname/$subcat";
$contenttitle = "Live Journal Icons $catname/$subcat";
include "header.php";
$images_dir = "/icons/";
$result_array = array();
$counter = 0;
$sid = (int)($_GET['sid']);
$cid = (int)($_GET['cid']);
//Are We Viewing a category?
if (empty($cid) && empty($sid)) {
//no?
echo "<h3>Please select a Category</h3>";
echo "<table border='0' cellspacing='0' cellpadding='5' width='100%'>";
echo "<tr>";
$cols = 4;
//fetch the categories
$query = mysql_query("SELECT c.cat_id as catid, c.cat_name as catname, COUNT(s.cat_id) AS subs FROM icon_categories as c LEFT JOIN icon_subcats as s ON c.cat_id = s.cat_id GROUP BY c.catname ASC");
while ($row = mysql_fetch_array($query))
{
if ($counter == $cols) {
$counter = 1;
echo "</tr><tr>";
} else {
$counter++;
echo "<td align='center'><a href='icons.php?cid=", $row['catid'], "'>", $row['catname'], "</a> (", $row['subs'], ")</td>";
}
}
echo "</tr></table>";
} else if (!empty($cid) && empty($sid)) {
//Yes?
echo "<h3>Please select a Sub-Category</h3>";
echo "<table border='0' cellspacing='0' cellpadding='5' width='100%'>";
echo "<tr>";
$cols = 3;
// fetch the sub categories
$query = mysql_query("SELECT sub_id as subid, sub_name as subname, cat_id FROM icon_subcats WHERE cat_id = '$cid' ORDER BY subname ASC");
while ($row = mysql_fetch_array($query))
{
if($counter == $cols) {
$counter = 0;
echo "</tr><tr>";
} else{
$counter++;
echo "<td align='left'><a href='icons.php?cid=", $cid, "&sid=", $row['subid'], "'>", $row['subname'], "</a></td>";
}
}
echo "</tr></table>";
}
--------------------------
----------
---
If you'd like to see it "in action" to see what I'm talking about - it's located at the following URL:
http://www.jeanies-creations.com/icons.phpThanks!