Dependent Drop Down lists in PHP and HTML
04:00 17 Jun 2019

I tried to implement a dependent drop down lists system. The code in contact.php page is:

connect_error){
        die("ERROR: Nu s-a putut realiza conexiunea la baza de date " .$link->connect_error);
    }

    $resultSet = $link->query("SELECT * FROM orase") or die('Error In Session');
    /* $rowsn = mysqli_fetch_array($resultSet);
    $n_oras=$rowsn['denumire_oras'];
    $id_orasss=$rowsn['id_oras'];    */                                         

    //$resultSetRep = $link->query("SELECT id_oras, denumire_rep FROM reprezentante where id_oras='$id_oras'") or die('Error In Session');                                                  
    //$rows1= mysqli_fetch_array($resultSetRep);
?>





    --head info



    

The first drop down list is working, it is retrieving the right data from table "orase" in the database: enter image description here

But for the second drop down, i want that, when i select the option "Braila" form the first drop down, to show the values from the database with the foreign key "id_oras" as the selected choice.

In this case, when I select "Braila" from the first drop down list, with the id_oras=1 in the table orase, I want that the second drop down list to retrieve data from the table "reprezentante" where id_oras = 1, in this case to retrieve values "Rep Braila" and "Rep Braila 2" to be shown in the drop down, but this is not happening..

enter image description here

This is a capture of the page: enter image description here

The code i posted is the best one i thought about, but still doesn't work.. please help me!

Thanks!

php html