How to insert data into a database based on which radio button is selected

I have a PHP form. It has multiple rows with data in it. Along with that there is a radio button that goes along with each record. If that radio button is checked that record (row of data gets added to the database) Multiple records(lines can be checked at once). I know I would have to check the name attribute of the radio button To see which buttons where checked. But how do I know which record goes with which checked radio button since I can have multiple buttons checked.

Thank You

With radio buttons, all buttons within a group (the choices to select one from) will all have the same name, but a different value.
so when you process the data, the value will be in the array under the group name.
Example:-

<fieldset>
                <legend>Choose your Colour</legend>
                <label>Red: <input type="radio" name="colour" value="red"></label>
                <label>Orange: <input type="radio" name="colour" value="orange"></label>
                <label>Yellow: <input type="radio" name="colour" value="yellow" checked></label>
</fieldset>

Then you will find the chosen value in $_POST['colour']

1 Like

I have uploaded my form layout I want to add/delete the column information to a database table that is under the headings:
Category Name, Website Name, Website Address.
Each row is a separate record (check box & radio buttons not stored in database)

Line Up Page 5.html (6.5 KB)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.