Java Dropdown menus with menu items from mysql database

Discussion in 'PHP' started by babaMBA, Aug 13, 2007.

  1. #1
    I want to show menus on my pages but i want that the menus atem are picked up from database.

    I used static menus with dhtml menu but i dont know how to make them dynamic based on mysql database. Some one help me how can i do that.
     
    babaMBA, Aug 13, 2007 IP
  2. jakomo

    jakomo Well-Known Member

    Messages:
    4,262
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    138
    #2
    Did you mean Java or Javascript?

    Best,
    Jakomo
     
    jakomo, Aug 13, 2007 IP
  3. Grumps

    Grumps Peon

    Messages:
    592
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thats easy, get those values from your database. For example, im going to make my menu with UL

    
    <ul>
    <?php
    $sql = mysql_query("your query here to retrieve the item");
    while ($row = mysql_fetch_array($sql)) {
    	echo "<li>$value</li>";
    }
    </ul>
    
    PHP:
     
    Grumps, Aug 13, 2007 IP
  4. babaMBA

    babaMBA Guest

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I want javascript drop down menus . when mouse move on "Products" menu open LIke "pro1 pro2 and so one"

    but i want these menus based on mysql database values.

    The li and ul are not menus
     
    babaMBA, Aug 14, 2007 IP
  5. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You're right they're not.. but just replace the li and ul with the correct tags :).

    
    <?php
    
    $query = mysql_fetch_assoc($sql);
    
    echo "<select name='blahblah'>";
    
    while (($row = mysql_fetch_assoc($query)))
    {
        echo "<option value='$row[id]'>$row[name]</option>"
    }
    
    echo "</select>";
    
    ?>
    
    PHP:
    Minus the foogly syntax I did ;)
     
    CodyRo, Aug 14, 2007 IP
  6. babaMBA

    babaMBA Guest

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    The ul or li tags or <option> tags this is all about html.

    I want to use javascript menus.

    e.g As shown on the top of this site. when u click on Fen stuff on the top bar a menu apper.

    I want to association of php and mysql and javascript to produce this type of dropdown menus.
     
    babaMBA, Aug 15, 2007 IP
  7. killerj

    killerj Active Member

    Messages:
    765
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    95
    #7
    I dont think anyone will give you a better example than that .It is not html as you think , it involves php and MYSQL codes to fetch elements . Please work on it .
     
    killerj, Aug 15, 2007 IP