Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Oct 2011
    Location
    Cambridgeshire, UK
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamic Drop Down Menu

    I have managed to write the code for a dynamic dropdown menu, as can be seen below.

    PHP Code:
    <?php
    include("../../includes/db/connect.php");

    $query "SELECT * FROM `termdates`";
    $result mysql_query($query) or die(mysql_error());

    $dropdown "<select name='term'>";
    while(
    $row mysql_fetch_assoc($result))
    {
    $dropdown .= "\r\n<option value='{$row['termID']}'>{$row['termText']}</option>";
    }
    $dropdown .= "\r\n</select>";
    echo 
    $dropdown;

    mysql_close();
    ?>
    However, depending on the value selected from the drop down menu, I need it to show the term dates for the year selected. Does any one have any suggestions?

    Thank you for any help in advance.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    I don't understand question.
    You're currently selecting everything without any conditions.
    Somewhere before the query, you need to specify a year and then
    create a condition in the query to only pull-out those rows that match the year.

    I guess I don't see what "year selected" means?

  • #3
    New Coder
    Join Date
    Oct 2011
    Location
    Cambridgeshire, UK
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I want it so that the user and select the academic year from the drop down menu, which is database driven and then it will query the database again and return the term dates for that academic year.

    Basically, like this (http://www.cromwellcc.org.uk/about/t...s/Default.aspx) but in PHP/mySQL.

    Thanks.

  • #4
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,453
    Thanks
    71
    Thanked 102 Times in 101 Posts
    Use Ajax for this, or Javascript.
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #5
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,502
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    If it's OK to refresh the screen, you won't need AJAX, but if
    you want it to be "fluid" changing, with a page refresh, you'll
    need to use AJAX (PHP and Javascripting).


  •  

    Posting Permissions

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