johnmayer
03-23-2004, 09:26 AM
I am trying to automate menu creation, I'm still somewhat new at this, I managed to get a navigation system to work, (index.php?sectionid=xx&pageid=xx). I'm pretty sure I have no idea here and am completely off but here goes...
<?php
$G1 = mysql_query('SELECT * FROM section WHERE category = 1');
$G2 = mysql_query('SELECT * FROM section WHERE category = 2');
$GRAB = mysql_query('SELECT * FROM nav WHERE sectionid = "'. $sectid. '"');
?>
<div id="leftnav">
<?php
while($nav = mysql_fetch_array($G1)) {
$sectid = $nav['sectionid'];
$titlea = $nav['title'];
echo '<div class="box"><div class="boxtitle">'. $titlea .'</div><ul>';
while($nava = mysql_fetch_array($GRAB)) {
echo '<li><a href="#">'. $nava['name'] .'</a></li>';
}
echo '</ul></div>';
}
?>
</div>
<div id="rightnav">
<?php
while($nav = mysql_fetch_array($G2)) {
$sectid=$nav['sectionid'];
$titlea = $nav['title'];
echo '<div class="box"><div class="boxtitle">'. $titlea .'</div><ul>';
while($nava = mysql_fetch_array($GRAB)) {
echo '<li><a href="#">'. $nava['name'] .'</a></li>';
}
echo '</ul></div>';
}
?>
</div>
I got all the boxtitles and boxes to show up, but the list items do not :| Database is simple now, until I get it to work...
table 'section' has 3 columns: "category", "sectionid", "title"
table 'nav' has 2 columns: "sectionid" & "name"
I am trying to implement this completely wrong?
<?php
$G1 = mysql_query('SELECT * FROM section WHERE category = 1');
$G2 = mysql_query('SELECT * FROM section WHERE category = 2');
$GRAB = mysql_query('SELECT * FROM nav WHERE sectionid = "'. $sectid. '"');
?>
<div id="leftnav">
<?php
while($nav = mysql_fetch_array($G1)) {
$sectid = $nav['sectionid'];
$titlea = $nav['title'];
echo '<div class="box"><div class="boxtitle">'. $titlea .'</div><ul>';
while($nava = mysql_fetch_array($GRAB)) {
echo '<li><a href="#">'. $nava['name'] .'</a></li>';
}
echo '</ul></div>';
}
?>
</div>
<div id="rightnav">
<?php
while($nav = mysql_fetch_array($G2)) {
$sectid=$nav['sectionid'];
$titlea = $nav['title'];
echo '<div class="box"><div class="boxtitle">'. $titlea .'</div><ul>';
while($nava = mysql_fetch_array($GRAB)) {
echo '<li><a href="#">'. $nava['name'] .'</a></li>';
}
echo '</ul></div>';
}
?>
</div>
I got all the boxtitles and boxes to show up, but the list items do not :| Database is simple now, until I get it to work...
table 'section' has 3 columns: "category", "sectionid", "title"
table 'nav' has 2 columns: "sectionid" & "name"
I am trying to implement this completely wrong?