michael1291 Posted June 17, 2011 Share Posted June 17, 2011 Hi, just wondering if anyone knows how to insert the value of a radio button to mysql and then when the page is refreshed it will display the radio button that was selected still. THANKS in advance for any help. Link to comment https://forums.phpfreaks.com/topic/239628-inserting-radio-button-value-mysql/ Share on other sites More sharing options...
The Little Guy Posted June 17, 2011 Share Posted June 17, 2011 <?php if(isset($_POST['submit']){ $rdo = mysql_real_escape_string($_POST['radioButton']); mysql_query("insert into my_table (radioBtn) values ('$rdo')"); // Redirect so we don't double post header("Location: {$_SERVER['PHP_SELF']}"); exit; } $sql = mysql_query("select * from my_table"); $row = mysql_fetch_assoc($sql); $checked = $row['checked']; ?> <form action="" method="post"> <input type="radio" name="radioButton" value="value1" <?php ($checked == "value1"?'checked="checked"':'') ?> /> Value1<br /> <input type="radio" name="radioButton" value="value2" <?php ($checked == "value2"?'checked="checked"':'') ?> /> Value2<br /> </form> Link to comment https://forums.phpfreaks.com/topic/239628-inserting-radio-button-value-mysql/#findComment-1231029 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.