Jump to content

INSERTING RADIO BUTTON VALUE - MYSQL


michael1291

Recommended Posts

<?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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.