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


#1

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?


#2

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/


#3

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…


#4

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.

:)

#5

Ok, I’ll try that. Thanks Carella


#6

Wouldn’t this be more like:

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

#7

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


#8

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.


#9

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