Page 1 of 1

Solved

Posted: Mon Apr 11, 2005 8:56 am
by Addos
Hi,
I’m not fully sure how to apply this but basically I have an update form and I want to have radio button fields filled with values that were previously checked when the form was first filled out.

In my database the column is headed ‘FullAddress’ and in this the data entered into the field could be either ‘Include_Address’ or ‘Dont_include_Address’ depending on what radio button had been checked.

At the moment I’m using this bit of code (below) but as I’m very new to all of this I’m not getting any result in that the page simply displays in the browser with neither radio buttons checked. I’m sure I can’t have two input values with the same id but I don’t fully know how to approach this.

This is a snip of my code:

Code: Select all

$updateSQL = sprintf("UPDATE applicants SET FullAddress=%s",
                                               GetSQLValueString($_POST['FullAddress'], "text"));


Do You Want Full Address Displayed<input type="radio" name="FullAddress" value="Include_Address" <?php if (!(strcmp($row_GetApplicantDetails['FullAddress'],""))) {echo "checked";} ?> >

Only Include County: <input type="radio" name="FullAddress" value="Dont_include_Address"<?php if (!(strcmp($row_GetApplicantDetails['FullAddress'],""))) {echo "checked";} ?> >
This is a snip of the code from the Form that would initially fill the values in the database.

Code: Select all

Do You Want  Full Address Displayed:<input type="radio" name="FullAddress" value="Include_Address" checked >
Only Include County: <input type="radio" name="FullAddress" value="Dont_include_Address" >
Many thanks for any advice.
Brian

Posted: Mon Apr 11, 2005 10:07 am
by Bennettman

Code: Select all

Do You Want Full Address Displayed: <input type="radio" name="FullAddress" value="Include_Address" <?php if ((strcmp($row_GetApplicantDetails['FullAddress'],"Include_Address")) === 0) {echo "checked";} ?> >
 
Only Include County: <input type="radio" name="FullAddress" value="Dont_include_Address"<?php if ((strcmp($row_GetApplicantDetails['FullAddress'],"Dont_include_Address")) === 0) {echo "checked";} ?> >
Have to put the second values in? I don't know what values you're comparing against.


Alternatively:

Code: Select all

<?php

// $row['fulladdress'] can be either "include" or "noinclude"
($row['fulladdress'] == 'include') ? $inc_check = ' checked' : $noinc_check = ' checked';


print <<<HTML

Do You Want Full Address Displayed: <input type="radio" name="FullAddress" value="Include_Address" $inc_check>
 
Only Include County: <input type="radio" name="FullAddress" value="Dont_include_Address" $noinc_check>

HTML;

?>