guys,
i really need a help with what I'm working at.
(first : sorry for my bad english, just hopping u understand what i want to ask here 🙂 )
I'm trying to make a drop down menu navigation for my website based on category and subcategory table.
I made two table to save the news category and sub category as follow :
-- Table structure for table `category`
CREATE TABLE IF NOT EXISTS `tb_cat` (
`cat_id` int(11) NOT NULL AUTO_INCREMENT,
`cat_name` varchar(225) NOT NULL,
`cat_sort` int(5) NOT NULL,
PRIMARY KEY (`cat_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
--
-- Table structure for table `subcategory`
CREATE TABLE IF NOT EXISTS `tb_sub` (
`sub_id` int(11) NOT NULL AUTO_INCREMENT,
`sub_name` varchar(225) NOT NULL,
`cat_name` varchar(225) NOT NULL,
`sub_sort` int(5) NOT NULL,
PRIMARY KEY (`sub_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
--
so, you can see that this two tables have a similiar field named cat_name
next I want to make drop down menu using these two tables like follow :
<ul>
<li><a href="#">Category 1</a>
<ul>
<li><a href="#">Sub Category 1a</a></li>
<li><a href="#">Sub Category 1b</a></li>
<li><a href="#">Sub Category 1c</a></li>
</ul>
</li>
<li><a href="#">Category 2</a>
<ul>
<li><a href="#">Sub Category 2a</a></li>
<li><a href="#">Sub Category 2b</a></li>
<ul>
</li>
</ul>
I dont find any hard trouble to make script for Category menu like follow :
<?php
$categoryi=mysql_query("SELECT * FROM tb_cat ORDER BY cat_sort,cat_name");
$no=1;
while ($r=mysql_fetch_array($category))
{
echo "
<li><a href=>$r[cat_name]</a>
<ul><li><a href=>SUB CATEGORY</a></li>
</ul>
</li>";
$no++;
}
?>
But i've already spent hours (and it make me nuts :p ) to find how to create script for SUB Category menu as above. Please give me a clue ....