I have an existing drop down menu that I am attempting to convert to PHP/MySQL to allow the client to edit the menu items. This is the structure:
Home-index.php
About Us-#
-about.php
-annualreport.php
-awards.php
Services-#
-services.php
-loans.php
and so forth. The query I'm using is:
select distinct mainlinks.id as daddyid, mainlinks.title as daddytitle, mainlinks.urlink as daddyurl, babylinks.id as babyid, babylinks.title as babytitle, babylinks.urlink as babyurl from mainlinks, babylinks where mainlinks.id = babylinks.parentid order by mainlinks.listorder";
And the result displayed with the code below:
$result = mysql_query($query) or die(mysql_error());
// keep track of previous maincategory
$previous_maincategory = NULL;
while ($row = mysql_fetch_assoc($result))
{
// if maincategory has changed from previouscategory then display it
if ($previous_maincategory != $row['daddytitle'])
{
echo "<strong><h2>" . strtoupper($row['daddytitle']) . "</h2></strong>";
}
echo '<a onclick="return confirmSubmit()" class="inside" href="deletesubcategory.php?id=';
echo $row['babyid'];
echo '">';
echo $row['babytitle'];
echo "</a>";
echo "<br/>";
// record what the previous category was
$previous_maincategory = $row['daddytitle'];
}
It only displays the items that have a child element, not the parent items that do not have child elements. Any ideas? I'm guessing the problem is with the query where clause but I can't figure out how to grab what I need. Thanks.