Hi been working on a small project, managed to do mostly everything else but i am stumped by the dynamic navigation system, i am working from a pre-existing database, the fields are like so:
CATEGORY_ID NAME
1 Cameras
2 Cameras>Camera Heads
3 Cameras>Camera Heads>SD
4 Cameras>Camera Heads>HD
5 Cameras>Camcorders
6 Cameras>Camcorders>SD
7 Cameras>Camcorders>HD
8 Camera Accessories
9 Camera Accessories>Matte Boxes
13 Lenses
14 Lenses>Broadcast
15 Lenses>Broadcast>SD
16 Lenses>Broadcast>HD
17 Lenses>Professional
18 Lenses>Professional>Specialist
19 Lenses>Adaptors
20 Lenses>Converters
21 Lenses>Controls
22 Lenses>Follow Focus
etc...
basically this is what i have done(left in the commented out code aswell):
function rentalmenu_Generator()
{
include('oracleonnect.php');
$query = oci_parse($conn,"SELECT HIRE_CATEGORY.* FROM WEBEQUIPMENT.HIRE_CATEGORY ORDER BY NAME");
ociexecute($query);
echo "<div id='container'>";
echo "<div id='content'>";
echo "<div class='menu-nav'>";
$call = array();
$i = 0;
while ($row = oci_fetch_array($query, OCI_BOTH))
{
$catid = $row['CATEGORY_ID'];
$menuname = $row['NAME'];
$strip = explode(">", $menuname);
//$toplevel = $name;
//if (strpos($menuname,">")===false)
//{
//$toplevel = $menuname;
//}else{
//$submenu = explode(">", $menuname);
//}
//echo $toplevel;
//echo "<br />";
$test = count($strip, COUNT_RECURSIVE);
//$max = max($strip);
//echo $max;
if ($test == 1)
{
$toplevel = $strip[0];
echo "<ul><li class='start'><a href='".$_SERVER['PHP_SELF']."?cat=".$catid."'>".$toplevel."</a></li></ul>";
$parents[] = $toplevel;
}else{
$toplevel2 = $strip[1];
echo "<li class='sub'><a href='".$_SERVER['PHP_SELF']."?cat=".$catid."'>".$toplevel2."</a>";
$submenu1[] = $toplevel2;
$call[$toplevel] = $toplevel2;
if (isset($strip[2]))
{
$toplevel1 = $strip[2];
echo "--><a href='".$_SERVER['PHP_SELF']."?cat=".$catid."'>".$toplevel1."</a></li>";
$submenu2[] = $toplevel1 ;
$call[$toplevel] = $toplevel1;
}else{
echo "</li>";
}
gen($call);
}
$i++;
//echo $i;
}
//print_r($call);
$num_rows = oci_num_rows($query);
$maxrecords = $num_rows;
$countparents = count($parents);
echo "<br />";echo "<br />";echo "<br />";echo "<br />";
$t = 0;
while($countparents < $maxrecords )
{
if(isset($parents[$t]))
{
echo $parents[$t];
$sub = 0;
if(isset($submenu1[$sub]))
{
while($submenu1[$sub])
{
echo "<br />";
echo "-->".$submenu1[$sub];
$sub++;
continue 1;
}
}
echo "<br />";
}else{
break;
}
$t++;
$countparents++;
}
//print_r($parents);
//print_r($submenu1);
echo "<br />";
echo "</div>";
echo "</div>";
echo "</div>";
ocifreestatement($query);
oci_close($conn);
}
I would like the structure to look like this:
<ul>
<li>Lenses</li>
<ul>
<li>Broadcast</li>
<ul>
<li>SD</li>
<li>HD</li>
</ul>
<li>Professional
<li>Professional
<ul>
Specialist
<li>Adaptors
<li>Converters
<li>Controls
<li>Follow Focus
</ul>
</ul>