Populating data in dropdown from database by ID

Question

have radio buttons on my form but when i clicked on radio it shows specific drop-down which get data from database table. But i need to get data in drop-down by foreign-key ID ?

Table name--ABC
id| fruitid   | name
1 |  1        | Apple
2 |  1        | Mango
3 |  2        | Veg-1
4 |  3        | Juice-1


getdata = "SELECT * FROM `ABC` WHERE `fruitid`= '$fruitid'
 if(mysqli_num_rows(getdata) > 0){
                         while($data= mysqli_fetch_assoc($getdata)){
                          $tid   = $data['fruitid'];
                           $name = $data[' name'];
                    ?>      
                <option value="<?php echo $tid; ?>"><?php echo $name; ?></option>
            ```
I stuck here i need to show data in drop-down by ID ?


0
Dev381 1 month 0 Answers 8 views 0

Leave an answer