Page 1 of 1

[SOLVED]Radio button checked or not

Posted: Wed Jul 07, 2004 11:08 pm
by Cateyes
HI guys I am trying to figure out how to show the box is checked or not checked from the data base I am trying to use the if and else statement here is the code which obviously doesn't work

Code: Select all

<?php
Limited Edtion :<?php if($row_rs_stock['LE'] == "Y") 
          <input name="checkbox" type="checkbox" value="checkbox" checked>;
		  else
		  if($row_rs_stock['LE'] == "N")
		  <input name="checkbox" type="checkbox" value="checkbox">; ?>
?>
The problem is that some of this is html code and I can't figure out how to correct it for php if this worked if the value equals yes it would show it checked otherwise N would show it unchecked.

Posted: Wed Jul 07, 2004 11:16 pm
by ol4pr0

Code: Select all

<input name="checkbox" type="checkbox" value="1">
if ($checkbox =='1')
{
#whatever
}

Posted: Wed Jul 07, 2004 11:19 pm
by Cateyes
Not sure I understand your response. The database has a Y or N response how do I use your suggestion if the DB responds with Y I want the box to show its checked otherwise it would be unchecked.

Posted: Wed Jul 07, 2004 11:31 pm
by Cateyes
OK your little post gave me an idea and this is my working code

Code: Select all

<?php
<?php 
		  if($row_rs_stock['LE'] == "Y") { 
          $LEBOX = "checked";
		 } else {
		  if($row_rs_stock['LE'] == "N")
		  $LEBOX = "unchecked"; } ?>
          Limited Edtion :<input name="checkbox" type="checkbox" value="checkbox" <?php echo $LEBOX; ?>>

?>