SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Mid-West
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question chainedSelectors: A Better Way to Drop-down a PHP List

    Hello PHP community,

    Iíve searched this site several times looking for a Chained Selector script that will access my database and update 4 menuís that relate back to each other.

    As an example: Menu 1 (year), Menu 2 (Make for that year), Menu 3 (Model for that make), Menu 4 (Body Style for that Model).

    An example web site would be www.cars.com when you go to sell a car. But cars.com is written in javascript and I would prefer to have this written in PHP if possible. I currently have a Chained Selector using the switch control command, but I must refresh the page for every new menu.

    I came across the ZEND website that had a tutorial on using PHP to create java script for the purpose I was looking for. But it only has 2 menus that are related and only calls to two tables in a database. But it is really nice because it doesnít refresh the page by using an array of data. Below is the url link:

    http://www.zend.com/zend/tut/drop-down.php

    What I would like know is if anyone would like to take a stab at changing the code to work with 4 drop down menus. Iíve been looking it over for 2 days and I havenít been able to make it work.
    If you would like the code posted let me know.

    Thanks,
    Bill

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi!
    wellcome to sitepoint
    Code:
    CREATE TABLE `submenu_items` (
      `id` int(11) NOT NULL auto_increment,
      `position` varchar(30) default NULL,
      `title` varchar(50) default NULL,
      PRIMARY KEY  (`id`)
    ) TYPE=MyISAM;
    now into the submenu javascript layer insert

    PHP Code:
    $ret mysql_query("SELECT * 
                        FROM submenu_items 
                        WHERE position = '2' 
                        ORDER BY id DESC"
    ); 
    this will update the second submenu layer....
    so u can insert into submenu on position 2 for submenu 2..
    hope it helps!
    cheers

  3. #3
    SitePoint Member
    Join Date
    Nov 2004
    Location
    Mid-West
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    reminder, thank you for your quick response. But could you please elaborate. Where would I put this code and how would it work.

    Thank you,
    Bill


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •