In php, how do I write 'if this particular radio button (ex. button1) was selected when clicking the submit button, echo "this"'? I have a table with 4 rows with each row containing 3 radio buttons.
Each button has a name and a value. If I remember correctly, the name can be the same, and the value can change. That way the name is assigned the value of the selected radio button, and you can decide what to do from there. http://www.w3schools.com/html/html_forms.asp
if (isset($_POST['submit'])){ if($_POST[$radio_button_id] == 'update'){ echo "we are updating";}} I've tried this and the comment didn't print. I'm basically saying here that if I selected on the update radio button when I clicked the submit button, then page should echo "we are updating." I am doing this for several rows by the way. the variable name '$radio_button_id' gives each row a different name.
Join our real-time social learning platform and learn together with your friends!