I have 3 radio buttons on my form A , B , C but when i clicked on A radio it shows specific dropdown which get data from database table but by fruitid 1 and when i clicked on B it will show data fruitid 2 as onnword. i need to show table data by specific fkid Id.

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

//////////////////////////////////////////////////////////////////

<select>
$getdata = mysqli_query($conn, "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>
                            <?php
                            } }?>
                    </select>

I want to get values in drop down by ID. as you see Table has fruitid it comes from anthor table and 3 radio buttons on the form when i click A radio it will show fruitid 1 and when i clicked on 2 it will show 2 fk accordingly . but now am stuck here ? any guideline please

I’m on my phone and it’s late so maybe I’m not understanding you correctly. Can you please show the code you have for the radio/drop down buttons?

Is what you’re saying that you don’t know how to code how to change the dropdown when a radio button is clicked? Are you using javascript?

commented: If you unable to understand any code so please don;t blame others , kindly first check if you have any soulution then rply otherwise dont waste time . +0

If you unable to understand any code so please don;t blame others

I understand your code perfectly. It’s what you are asking that I am confused by.

I asked for clarification so I can help you.

commented: can i usse isset($_post[id]) $fruitid = $_Post['id'] +0

can i usse isset($_post[id]) $fruitid = $_Post['id']

Yes, you can do something like:

if (isset($_POST['id'])) {
    // We make sure to sanitize the user input by making sure it's an integer
    //   since we will be using it in our SQL query
    $fruitid = intval($_POST['id']);
}

$getdata = mysql_query($conn, "SELECT * FROM ABC where fruitid = $fruitid");
commented: but nothing load in dropdwon +0

Is what you’re saying that you don’t know how to code how to change the dropdown when a radio button is clicked? Are you using javascript?

My question in my previous post was me asking if you needed help sending the $POST data. For example, are you using Javascript to trigger AJAX behavior when a radio button is selected by the end-user?

commented: yes ajax method to load a radio buttons +0

@Deve381 Why dont you do some research on how to use Ajax to return the data you need, there is a vast amount of tutorials on the subject if you Google it!
You will learn more by doing this then just getting solutions off of people.
Perhaps when you then have something more substantial code wise then people may be more willing to help you.
I find your replies quite aggressive and blunt to the point.

I will repeat what I asked in my first post of the thread: Can you please show the html/javascript code for the dropdowns?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.