Web Analytics Made Easy -
StatCounter Dual Dropdown doesn't refresh - CodingForum


No announcement yet.

Dual Dropdown doesn't refresh

  • Filter
  • Time
  • Show
Clear All
new posts

  • Dual Dropdown doesn't refresh

    I have this code that I use to display and grab data from 2 tables in mysql into 2 dropdown menus.

    When I select in dropdown menu 1 an item (with ID in database, the first table has fields: ProgrammaID, Programma).

    Then in de second dropdown menu the particulair item with this same ID as the selected one in menu 1 need to be shown.
    The second table has fields: ProjectID, ProgrammaID, Project.

    The ProgrammaID from table1 is also in table2 (designed by our previous designer).

    Now I can select an item from dropdown menu 1 but the second dropdown menu isn't shown the items as should be.

    Here is the code I use:
    PHP Code:
    $query "SELECT DISTINCT Programma FROM hesk_programma ";
    $result mysql_query($query) or die ( ' error in query ' );
    $Programma_options "";
    $Project_options "";
    while (
    $row mysql_fetch_array($result)) {
    $id $row["ProgrammaID"];
    $Programma $row["Programma"];
    $Programma_options .= "<option value=\"$id\" onSelect=\"top.location='".$_SERVER['PHP_SELF']."?ProgrammaID=".$id."';\">".$Programma."</option>";
    if ( isset(
    $_GET['ProgrammaID']) ) {
    $query "SELECT * FROM hesk_projecten WHERE ProgrammaID={$_GET['ProgrammaID']}";
    $result mysql_query($query) or die ( ' error in query ' );
        while (
    $row=mysql_fetch_array($result)) {
    $Project_options .= "<option value=".$row['ProjectID'].">".$row['Project']."</option>";
    <form method="GET">
    <select name="selectcountry">
    <option value="0">Kies Programma</option>
    <?php echo $Programma_options?>
    <select name="selectcity">
    <option value="0">Kies Project</option>
    <?php echo $Project_options?>

  • #2
    Do a search on chained selects. Someone with more experience may know for certain, but I'm pretty sure your current code will just refresh the page, resetting the form. So the ProgrammaID is being lost on the page refresh to query and create the second drop down list.