I've a working code and display well. Now I want to integrate into html code but I don't know how to add a custom div into it.
Here's my php
function hasChild($parent_id)
{
$sql = "SELECT COUNT(*) as count FROM w_category WHERE ParentID = '" . $parent_id . "'";
$qry = mysql_query($sql);
$rs = mysql_fetch_array($qry);
return $rs['count'];
}
function CategoryTree($list,$parent,$append)
{
$list = '<a href="dd">'.$parent['Name'].'</a>';
if (hasChild($parent['ID'])) // check if the id has a child
{
$append++;
$list .= "<ul class='child child".$append."'>";
$sql = "SELECT * FROM w_category WHERE ParentID = '" . $parent['ID'] . "'";
$qry = mysql_query($sql);
$child = mysql_fetch_array($qry);
do{
$list .= CategoryTree($list,$child,$append);
}while($child = mysql_fetch_array($qry));
$list .= "</ul>";
}
return $list;
}
function CategoryList()
{
$list = "";
$sql = "SELECT * FROM w_category WHERE (ParentID = 0 OR ParentID IS NULL)";
$qry = mysql_query($sql);
$parent = mysql_fetch_array($qry);
$mainlist = '
<ul class="nav">';
do{
$mainlist .= CategoryTree($list,$parent,$append = 0);
}while($parent = mysql_fetch_array($qry));
$list .= '</ul>
';
return $mainlist;
}
Here is my html:
<ul class="primary-nav">
<li><a class="active-page" href="index.html">Home</a></li>
<li><a href="#">Pages</a>
<div class="submenu_wrapper column4">
<ul>
<li><a href="index.html">Homepage A</a></li>
<li><a href="index2.html">Homepage B</a></li>
<li><a href="index3.html">Homepage C</a></li>
<li><a href="boxed.html">Boxed Layout</a></li>
<li><a href="background-slideshow.html">Background Slideshow</a></li>
<li><a href="category-grid.html">Category Grid</a></li>
</ul>
</div>
</ul>
my code is working well for ul and li tag but I want to add
<div class="submenu_wrapper column4"> and </div> once there is sub-category.
Please help me.