Hello, I think I am trying to understand how to change a RadioButton value during an UPDATE transaction, not Insert, not Retrieve.
With an INSERT INTO I can insert a “0” or a “1” into a table field by means of a RADIO BUTTON like so:
PageInsert.php:
<form name="form1" id="form1" method="post" action="PageInsert_Process.php?myID=<?php echo $myID ?>">
<input type="radio" name="OPT1" id="OPT1 value="1" /> (Yes)
<input type="radio" name="OPT1" id="OPT1" value="0" /> (No)
<!-- etc... -->
Then in
PageInsert_Process.php?myID=99 :
[php]
//stuff here
$OPT1 = $_POST[‘OPT1’];
//stuff here
// INSERT INTO query here, etc.
[/php]
The above works as expected and the RADIOBUTTON field (OPT1) is INSERTED with a 0 or 1 respectively.
For the same table from above, I also have an UPDATE form, as follow:
PageUpdate.php?myID=99 :
<form name="form1" id="form1" method="post" action="PageUpdate_Process.php?myID=<?php echo $myID ?>">
<input type="radio" name="OPT1" id="OPT1 value="1" <?php if ($OPT1 == 1) { echo " checked"; }?>/> (Yes)
<input type="radio" name="OPT1" id="OPT1 value="0" <?php if ($OPT1 == 0) { echo " checked"; }?>/> (No)
<!-- etc... -->
So the above form show me the CURRENT status(value) of the RADIOBUTTON as it is in the table.
With this same update form, I can ofcourse change the RADIOBUTTON from Yes(1) to No(0) or vice-versa.
The problem I have is that when I do an UPDATE, it always takes the “1” value, never the “0”.
PageUpdate_Proccess.php?myID=99 :
[php]
//stuff here
$OPT1 = (isset($_POST[‘OPT1’])) ? 1 : 0;
//stuff here
// UPDATE query here, etc.
[/php]
Yes I am new to php/mysql.
Please point me in the right direction.
Thank you kindly,
Jamie.