HELP!! - Boolean edit field in PHP -radio button group???

This is an edit field on a php edit records page (for a car sales site), created with Dreamweaver MX. The field, ‘stereo’, is boolean and must only accept the values, 0 (no, car does not have stereo) and 1 (yes, car has stereo).

Stereo

How do I code this instead on a radio button group, or similar?

Again, this is a PHPHelp forum. We provide HELP on PHP. This is NOT the HTML Help for HTML help, (again, thanks for the hint to Carella) please check http://www.webmasterworld.com/forum21/

Look, I know HTML… It is PHP I am unfamiliar with, and as far as I’m concerned, this is a PHP problem, as it involves dynamic content being edited…

Hi joh,

You can use a few things to get your boolean data, like an if statement, or a switch statement, however in these situations I like to use whats called a Ternary Operator.

Like this:

[php]

[/php]

If $row_Recordset1[‘Stereo’] has some data, then it will be true and display 1, if not, it will be false and display 0.

Hope that works.

:)

Ok, I’ll try that. Thanks Carella

Wouldn’t this be more like:

<input type="text" name="Stereo" value="1"<?php echo $row_Recordset1['Stereo'] ? " checked" : NULL; ?>" size="32"> 

Not if its a text input field I dont think. :)

Ouch! I’m working on multi-form input to locked xml hotfile, and I made classes for different inputs - had been staring at checkboxes and radiobuttons for like 2 hours when I read that - didn’t even notice it was a text field. My bad, sorry if I confused anyone, I’ll make sure not to forget the coffee tomorrow.

LOL! Don`t worry, I know the feeling.

Sponsor our Newsletter | Privacy Policy | Terms of Service