Problem with SWITCH function in Radio Button group
I have a radio group with two radio buttons (new & used). I also have a current_value that reads the records current value in the database. I want the correct radio button to be 'true' base on the current_value field
Here is my code that I current have. But it doesn't work:
PHP Code:
PHP Code:
<td> Current value of listing:
<input name="current_value" type="text" class="formelements" id="current_value" value="<? print "$new_used"; ?>" disabled="true" size="10">
Edit listing to be
<?
// CHECKS TO SEE WHAT THE CURRENT VALUE IS AND POPULATES THE CORRECT RADIO BUTTON BELOW
$value = 'current_value';
switch ($value === 0 ? '' : $value) {
case 'new':
echo $new = true;
break;
case 'used':
echo $used = true;
break;
}
?> <input name="new_used" type="radio" class="formelements" id="new" value="new">new or
<input name="new_used" type="radio" class="formelements" id="used" value="used">pre-owned
</td>
this is a wrong way to use Switch !!
first of all you are giving the value to $value which is 'current_value' so all the switch statment is usless ,,
you may use it like this :
PHP Code:
switch ($value) {
case 'new':
$new = true;
break;
case 'used':
$used = true;
break;
case false:
$value = '';
break;
}
__________________ PHPSimplicity
We don't need a reason to help people - Zidane [FF9]