In php form I get the data from radio button to database. It works well. But in edit page how do I get the checked value from database?
<td align="left" valign="middle"><input name="signi" type="radio" id="signi" value="S"/> YES
<input name="signi" type="radio" id="signi" value="N" /> No</td></td>
Do like this in your edit page:
Take database value in variable:
Example:
<?php $signi= $row['signi']; ?>
And :
<td align="left" valign="middle">
<input name="signi" type="radio" id="signi" value="S" <?php echo ($signi== 'Yes') ? "checked" : "" ; ?>/> YES
<input name="signi" type="radio" id="signi" value="N" <?php echo ($signi== 'No') ? "checked" : "" ; ?>/> No</td></td>
Check this thread for details:
you have to check database value first and then set checked property to checked if true
<input name="signi" type="radio" id="signi" value="S" <?php if($row["signi"]=="S"){echo "checked=\"checked\" "} ?> />`
You can do it like this. when you fetch record from table you will be outputting the other data on the form. Let suppose $row
is a php variable which contains the record.
if($row['checkboxfieldname'] == 'my required condition'){
?> <input type = 'checkbox' value = '1' name = 'blahblah' checked> <?
}else{
?> <input type = 'checkbox' value = '1' name = 'blahblah'> <?
}
Get the value of that radio button :
<?php $signi= $row['signi']; ?>
Then in HTML
<td align="left" valign="middle">
<input name="signi" type="radio" id="signi" value="S" <?php if($signi=='S'){ echo "checked=checked";} ?>/> YES
<input name="signi" type="radio" id="signi" value="N" <?php if($signi=='N'){ echo "checked=checked";} ?>/> No</td></td>