Hi,
I been trying to figure out how to do this but I have no luck in finding out how to...
I have a vertical list menu... I want to load the main menu titles from the database and I want to load the sub menu from the database..
<ul>
<li><a href="#">main menu</a>
<ul>Sub menu</ul>
</li>
<li><a href="#">main menu 1</a>
<ul>Sub menu</ul>
</li>
<li><a href="#">main menu 2</a>
<ul>Sub menu</ul>
</li>
<li><a href="#">main menu 3</a>
<ul>Sub menu</ul>
</li>
</ul>
I tried this it works but it doesn't group them it prints
the main category then the sub menu... it prints out the main
category again and again and the sub menu.. like if there's 2
sub menu's that's meant to be under a certain main category
say for example. Home is the main category it does this:
Home
Tables
Home
Lounge Suites
It does each sub menu seperately...
<?
$conn = pg_connect ("host= localhost port=5432 dbname=test");
#==============================================================
$sql = "SELECT DISTINCT tblproductcategory.productcategoryid,tblproductcategory.productcategory, tblproducttype.productcategoryid,tblproducttype.producttype FROM tblproductcategory";
$sql .= " INNER JOIN tblproducttype ON tblproducttype.productcategoryid = tblproductcategory.productcategoryid";
$sql .= " GROUP BY tblproductcategory.productcategoryid,tblproductcategory.productcategory, tblproducttype.productcategoryid,tblproducttype.producttype";
$sql .= " ORDER BY tblproductcategory.productcategoryid,tblproductcategory.productcategory, tblproducttype.productcategoryid,tblproducttype.producttype";
$r_query = pg_query($conn, $sql);
while($arr=pg_fetch_array($r_query))
{
If($arr[1] <> $arr[1]){
Print "<b>".$arr[1]."</b><br>";
}
Print $arr[3]."<br>";
}
?>