Web Analytics Made Easy -
StatCounter Dropdown Menu to Autopopulate - CodingForum

Announcement

Collapse
No announcement yet.

Dropdown Menu to Autopopulate

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dropdown Menu to Autopopulate

    Hi,

    I have a dropdown menu that pulls data from our inventory database. I want to make it more dynamic so that when we add items, we don't have to manually add it to the menu. Is there a way to cause the dropdown to autopopulate with the current items? Also, is there a way to make the menu not show items that are out of stock?

    I'm not sure what would be better for this...PHP or ASP.net. I'm a rookie at both!

    Thank in advance!!
    Beth

    [CODE]
    <!-- boys themes -->
    <form action="deluxeSFshop.aspx" name="searchbox" id="searchbox">
    <input type='hidden' name='sfid' value=87970 >
    <select name="c" id="c">
    <option value="0" selected>pick boys theme</option>
    <option value="156240">animals</option>
    <option value="156248">backyardigans</option>
    <option value="156249">blues clues</option>
    <option value="156250">bob the builder</option>
    <option value="156261">buzz lightyear</option>
    <option value="156262">cars (disney)</option>
    <option value="156251">cars-trucks-planes</option>
    <option value="156257">cowboys</option>
    <option value="156254">motorcycles</option>
    <option value="156264">nemo</option>
    <option value="156329">MORE THEMES</option>
    </select>
    <input style="border:1px solid #4d4d4d;background-color:#99cccc;color:#fff;font-weight:bold;font-size:10px;font-family:Arial, Helvetica, sans-serif;padding:2px;" type="submit" name="submit" id="go" value="GO">
    </form>
    [CODE]

  • #2
    This is a PHP/MySQL solution I modified from what I use, and should put you on the right track. I'm not sure if WHERE items_remaining != '0' is the correct syntax but the idea is to only display records that do not equal 0.



    Untested
    PHP Code:
    <form action="deluxeSFshop.php" name="searchbox" id="searchbox">
    <input type='hidden' name='sfid' value=87970 >
    <select name="c" id="c">
    <option value="0" selected>pick boys theme</option>

    <?php
    $sql 
    mysql_query("SELECT * FROM inventory WHERE items_remaining != '0' ORDER BY item_name ASC");
    while(
    $row mysql_fetch_array($sql)){
    echo 
    "<option value=\"$row[sku]\">$row[item_name]</option>";
    }
    ?>
    </select>
    <input type="submit" name="submit" id="go" value="GO">
    </form>


    ---
    Last edited by Len Whistler; Apr 10, 2009, 05:02 PM.
    Leonard Whistler

    Comment

    Working...
    X