Jump to content


Photo

single line "if statement"


  • Please log in to reply
2 replies to this topic

#1 djanim8

djanim8
  • Members
  • PipPipPip
  • Advanced Member
  • 42 posts

Posted 16 August 2006 - 06:44 PM

I'm getting errors on this line of code:

<option value="1" <?PHP if($row["catagoryNum"] == "1") { echo "selected" } ?>>Option 1</option>

can you have an if statement on a single line? or do I have to convert it to this:

<option value="1"
<?PHP
if($row["catagoryNum"] == "1") {
echo "selected"
}
?>
>Option 1</option>

#2 bbaker

bbaker
  • Members
  • PipPipPip
  • Advanced Member
  • 127 posts
  • LocationNY

Posted 16 August 2006 - 06:50 PM

try adding a space between the >>
<option value="1" <?PHP if($row["catagoryNum"] == "1") { echo "selected" } ?> >Option 1</option>

actually,

try adding a ; after "selected"
<option value="1" <?PHP if($row["catagoryNum"] == "1") { echo "selected"; } ?> >Option 1</option>

#3 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 16 August 2006 - 11:46 PM

it's the ;
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users