p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: Radio Boxes in Forms


Message #1 by Empier4552@a... on Mon, 28 Oct 2002 20:14:23 EST
I have a script right now that retrieves info from a database and echos it 
mostly out into a form. However severla values are 1 or 0 (true or false 
basically). There are radio boxes for a person to pick either true or false. 
I'd like for the value stored in the database to be the one checked by 
default. Usually an if and echo together would achieve this however all of 
the script is being put into a variable as shown below. 
Excuse any misformed <p> tags etc.

$display = "
<form name=\"form1\" method=\"post\" action=\"do_create.php\">
          <p>Company Name: 
            <input name=\"cname\" type=\"text\" id=\"cname\">
          </p>
          <p>Contact Email: 
            <input name=\"cemail\" type=\"text\" id=\"cemail\">
          </p>
          <p>Password: 
            <input name=\"password\" type=\"password\" id=\"password\">
          </p>
           <p>Capital-?: Yes- 
HERE IS WHERE THE CHECK SHOULD BE DONE. EITHER 1 OR 0 SHOULD BE CHECKED 
DEPENDENT UPON THE VALUE IN THE DB- WHAT KIND OF STATEMENT SHOULD I USE? PHP 
Commands give parse errors
            <input type=\"radio\" name=\"capital\" value=\"1\" CHECKED HERE 
IF 1> 
            No- 
            <input name=\"capital\" type=\"radio\" value=\"0\"  CHECKED HERE 
IF 0>
            <input type=\"submit\" name=\"Submit\" value=\"Create">
          </p>
        </form>
";
?>


  Return to Index