简体   繁体   中英

Retrieving Combobox selected value php

I have created a dynamic combobox with data from an ORACLE DATABASE in PHP, but I need to retrieve the information selected from the user.

Here is what i've got so far:

<?php
$conn = oci_connect('DBadmin', 'dbadmin', 'PETLOVERSDB');
if (!$conn) {
    $e = oci_error();
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
} 
            $query= 'select PET_RACE_NAME from petrace';
            $stmt = oci_parse($conn, $query);
            oci_execute($stmt);

            echo '<select name="pet_breed">';
            echo '<option value = "-1">Select Type:</option>';

                while($row=oci_fetch_assoc($stmt)) {
                     echo '<option>' . $row['PET_RACE_NAME'] . '</option>';
                }
                     echo '</select>';  
            $Result = $_POST['pet_breed'];

?>  

I read that I can use the methods $_POST and $_GET but I can't get it to work exactly, what could I do?

I would really appreciate your help!

You could attempt to use something like jquery to help with dynamically loading the boxes. The way it works is the user selects an item, passes it through jquery and to a php file where it then checks for the data, and then returns the database back to the page via jquery once again. There are plenty of tutorials that may help with the examples. Here's one for instance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM