PHP and JavaScript drop down menus

Discussion in 'PHP' started by babaMBA, Jul 20, 2007.

  1. #1
    I want to make java menus but link them with my database in mysql , before that i make only static drop down menus.

    This time i need a dynamic menus that get the links from database.

    How can i do that .............. ?

    Thx in advance
     
    babaMBA, Jul 20, 2007 IP
  2. nabil_kadimi

    nabil_kadimi Well-Known Member

    Messages:
    1,065
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    195
    #2
    you can create dynamicly your javascript like any HTML, make sure thet your javascript is parsed.
     
    nabil_kadimi, Jul 20, 2007 IP
  3. Vbot

    Vbot Peon

    Messages:
    107
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #3
    $q = mysql_query("SELECT * FROM table");
    while($row = mysql_fetch_array($q))
    {
        $opt .= "<option value='{$row['field1']}'>{$row['field2']}</option>";
    }
    echo "<select name='list'>$opt</select>";
    PHP:
    Just change the selection list with your javascript list. That should work.
     
    Vbot, Jul 20, 2007 IP