View Full Version : Adding a sub sub category

01-04-2012, 01:53 AM
Hey guy's, This is my first time posting on these forums, Please be kind ^_^

Is it possible to add a sub sub category to this code? If so could you give me a quick explanation on how to do that?

---sub sub

<? echo ' <select name="catergory_id">
<option value="0">None</option>';
$sql2 = $db->query("SELECT * FROM `{$SQL_Ext}_cats` WHERE `parentid` = '0' ORDER by `name`");
while ($row2 = $db->fetch_assoc($sql2))
if ($row2['id'] == $theQuery['parentid'])
echo '<option value="'.$row2['id'].'" selected>'.$row2['name'].'</option>';

elseif ($row2['id'] == $theQuery['id'])


elseif ($row2['id'] == 0)
echo '<option value="0" selected>None</option>';
echo '<option value="'.$row2['id'].'">'.$row2['name'].'</option>';
echo '</select>'

01-04-2012, 02:19 PM
SELECT tags cannot have nested SELECT's. I mean, you could put them in there, but your browser wouldn't know how to handle it.

Your only solution would be to display the nesting with some sort of indentation; whether that's a space or a '-'.

01-04-2012, 03:08 PM
Scroll to the bottom of this page and look at the thing called 'Forum Jump'.

Right click on the page and view source. See how thats structured and then have a think about it in php.

As for each item having a sub item (presumably you want this related in the database?) the way to do that is for each item to have a PARENT. Each item has its own id in the table right? - So its sub items PARENT would be set to that items id if you get my drift..