Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6191093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:42:11+00:00 2026-05-24T02:42:11+00:00

I have an existing drop down menu that I am attempting to convert to

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T02:42:11+00:00Added an answer on May 24, 2026 at 2:42 am

    You have to use LEFT JOIN to get items which don’t have childs, try

    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 
      LEFT JOIN babylinks ON mainlinks.id = babylinks.parentid
    order by mainlinks.listorder;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a drop down menu on a remote page whose source i can
I am relatively new to PHP/MySQL and have been having a problem that I
I have to create the Jquery Grid that have check boxes and drop down.
I have existing code that uses CMNewProfileSearch to find then iterate over the color
I have existing java code and need to create Design Document based on that.
I'm working on a project where the client wants to have existing pages dynamically
For whatever reason, I have a lot of clients that have existing data that's
We have an existing WCF service that makes use of wsDualHttpBinding to enable callbacks
I have a drop down in one of my views, allowing me to select
I have a web form with two drop-down boxes, and I'm looking for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.