- Impact
- 11
How will i be able to order my sub-categories under my parent?
Right now they show up as:
-Parent 1
-Parent 2
-Parent 3
-Parent 4
---Sub-Categories of 1
---Sub-Categories of 2
---Sub-Categories of 3
---Sub-Categories of 4
My code is:
Right now they show up as:
-Parent 1
-Parent 2
-Parent 3
-Parent 4
---Sub-Categories of 1
---Sub-Categories of 2
---Sub-Categories of 3
---Sub-Categories of 4
My code is:
PHP:
$cat.='<select size="1" name="category" size="36" maxlength="255">';
$cat.='<OPTION VALUE="___" selected>Select A Category</OPTION>';
$sql_query_cat = "SELECT * FROM categories ORDER BY parent ASC";
//store the SQL query in the result variable
$result_cat = mysql_query($sql_query_cat);
if(mysql_num_rows($result_cat))
{
//output as long as there are still available fields
while($row = mysql_fetch_array($result_cat))
{
$parent = stripslashes($row[parent]);
$categ = $row[title];
$categ = stripslashes($categ);
if($parent=='0'){
$cat.='<option>-'.$categ.'</option>';
}else{
$cat.='<option>---'.$categ.'</option>';
}
}
}
$cat.='</select>';





