The groups has their own table, I want all top groups and sub groups in same table because when you create a new sub category (group) within another category from the online editor tool, then you can't really create a new table for every sub category. That wouldn't sound right to me.
The data that will be stored in this top categories, sub categories are in a different table and that's not what I have problem with. The problem is the select box, I want the the categories to be ordered in right way.
I use this code now:
Code: Select all
$result = mysql_query("SELECT * FROM cyberwear_categories",$connect);
$numrows = mysql_num_rows($result);
if ($numrows>0){
while($load = mysql_fetch_array(mysql_query("SELECT * FROM cyberwear_categories",$connect))){
if ($load['level']==0){
echo "<option value='".$load['uid']."'>".ucwords($load['name'])."</option>";
}
else{
echo "<option value='".$load['uid']."'>--".ucwords($load['name'])."</option>";
}
}
}
else{
echo "<option>None Available</option>";
}
As you can see sub categories will be shown like --my sub category. However these will not be listed under correct top category. So I want the listing in the selection box to be as this:
Code: Select all
category#01 (first top category that has level 0)
--subcategory#01 (first sub category that has level 1)
----subcategory#02 (second sub category that has level 2)
category#02 (second top category that has level 0)
--subcategory#03 (first sub category that has level 1)
It shouldn't matter how many sub categories one has, so I think I must use some sort of loop but not sure how. I hope this make some sense, I might be using wrong database structure or just missing some php code.