- Impact
- 11
Im working on the menu at my site http://tutorialhit.com/index.php
i want to be able to click the main category (in this case, only one is there, and called PHP coding) and it would display all of the sub-categories in only that category (there will be more main categories added). Then if you click the PHP coding category again, the sub-categories go away again.
The categories are all in the mysql database
This is the code for the subcategories
If you dont know what i mean, i found an example: http://www.chipchapin.com/WebTools/MenuTools/xpandmenu-2004-12-16/demo_win.php
If i know the code on how to make you click on a link and gives text to a certain variable but the page doesnt reload or something, then i can probably do it.
Ie
i want to be able to click the main category (in this case, only one is there, and called PHP coding) and it would display all of the sub-categories in only that category (there will be more main categories added). Then if you click the PHP coding category again, the sub-categories go away again.
The categories are all in the mysql database
This is the code for the subcategories
PHP:
if(count($children)>"0"&&$foetus!="") {
foreach($children as $child) {
$k++;
$title = mysql_result(mysql_query("SELECT * FROM tdb_categories WHERE id='$child' LIMIT 1"), "0", "title");
$stati = mysql_result(mysql_query("SELECT * FROM tdb_categories WHERE id='$child' LIMIT 1"), "0", "status");
if($stati=="open") {
$colspan = "1";
$link = '<a href="list.php?cat='.$child.'">'.$title.'</a></td><td class="info">'.mysql_numrows(mysql_query("SELECT * FROM tdb_tutorials WHERE cat='$child' AND status='accepted'")).' ×';
} else {
$link = ''.$title.'';
$colspan = "2";
}
echo '<tr class="menu'.$k.'subcat"><td class="link" colspan="'.$colspan.'">'.$link.'</td></tr>';
if($k=="2") {
$k = "0";
}
}
}
If you dont know what i mean, i found an example: http://www.chipchapin.com/WebTools/MenuTools/xpandmenu-2004-12-16/demo_win.php
If i know the code on how to make you click on a link and gives text to a certain variable but the page doesnt reload or something, then i can probably do it.
Ie
PHP:
$activelink="";
//code to click the text below and add $title (category title) to the variable
Category name
// Then display sub-categories whos parent is $title (category title that was clicked)
Last edited:





