I have a radio box that has a php variable name in its radio name. How can I pass its value to another PHP file and it will become like this, for example:

<input type='radio' name='choice_a' value='$answer'>

It will become a $_POST['choice_a'] after I pass it in another page. But if its like this:

<input type='radio' name='$quiz_no' value='$answer'>

How can its name be passed in another PHP file for checking? By the way, the $quiz_no and $answer is stored in my database.

If the above code is html (not php) then you have to do it this way:

<input type='radio' name='choice_a' value='<?php echo $answer;?>'>
<input type='radio' name='$quiz_no' value='<?php echo $answer;?>'>

To pass this to another php file for checking / processing enclose fields in form tags and set action attribute (and add a submit button):

<form action="anotherfile.php" method="post">
<input type='radio' name='choice_a' value='<?php echo $answer;?>'>
<input type='radio' name='$quiz_no' value='<?php echo $answer;?>'>
<input type="submit" name="submit" value="Submit">
</form>

In your action page fetch all field names from database
&
in your while loop get tha posted values like $_POST['$row->yourFieldName']

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.