I want to create a list which contains categories and on hover the category i need to display sub categories.I am able to display the parent categories in list.but couldn't understand how to get sub categories for that. In my table i have category_id, parent_id column and some other columns. If parent_id is '0' it is main category and for subcategories it contains there category_id.So now i need to display sub-categories for main categories.I could not understand how to proceed.Can any one give advice.
<ul class="betterList">
<?php
$con = mysql_connect("localhost","root","pwd") or die('couldnot connect to database'.mysql_error());
mysql_select_db("DB",$con);
$result=mysql_query("select * from table order by `name_en-GB`")or die("No table available with this name"."<br/><br/>".mysql_error());
while($row=mysql_fetch_array($result))
{
$parent_id=$row['category_parent_id'];
$category_id=$row['category_id'];
if($parent_id==0)
{
?>
<li><?php echo $row['name_en-GB'];?></li>
<?php }
?>
<ul id="internal" style=" margin:0px;
padding:0;"><li><?php //echo $row['name_en-GB']; ?></li><li>data</li></ul></li>
<?php
}?>
</ul>