Easy Programming Question. Arrays specifically

What I usually do in a case like this is to have one MENU table with fields for levels and parents. Then in one query I either get every item, grouped by level and parent. So the dataset returned is like uhm…



ID Text Level ParentID
1 Animals 0 0
2 Dogs 1 1
3 Beagles 2 2
4 Great Danes 2 2
5 Cats 1 1
6 Calico 2 5
7 Tabby 2 5
8 Cars 0 0
9 American 1 8
10 Ford 2 9
11 Chevy 2 9
12 Japanese 1 8
13 Toyota 2 12
14 Honda 2 12


Then I use server-side code to spit out HTML around those items based on their level and parentID, ending up with HTML like



<ul>
<li>Animals
     <ul><li>Dogs
          <ul><li>Beagles</li>
          <li>Great Danes</li></ul>
      </li>
     <li>Cats
          <ul><li>Calico</li>
          <li>Tabby</li></ul>
     </li></ul>
</li>
<li>Cars
     <ul><li>American
          <ul><li>Ford</li>
          <li>Chevy</li></ul>
     </li>
    <li>Japanese 
         <ul><li>Toyota</li>
         <li>Honda</li></ul>
     </li>
</li>
</ul>


Is that the sort of thing you want to do, or do you really need actual lookups because it’s an actual “combination chooser” instead of defined lists?

Perhaps if you Google “php ajax menu” or “php ajax dropdown” that might give you some more insight, too?

I laughed. :slight_smile:

I found something through googling that hands off a PHP array to Javascript using, as far as I can figure, magic. Basically what I have is two selection panes with a 3rd pane showing a list. For example, the left pane would be:

Mammals / Dogs, Cats
Fish / Trout Tuna

The middle pane would be:

Action / Playing, Eating

The right pane would then display links according to the selection. The links then would open the corresponding picture in the rest of the window.

I’ve got it working now though, so thanks for everyone’s help.