Page 1 of 1

php error with html

Posted: Sun Mar 28, 2004 3:44 pm
by kapturedsoul
I am VERY new to Php...I can't seem to find good information on the interaction with html

I am getting an error...

I have

Code: Select all

if
{

php code

}

else
{
html code
}
I am getting an error at the line of the first html code...it doesn't like it being in php... but i need php tags for the else{}

please help!

Posted: Sun Mar 28, 2004 3:46 pm
by markl999

Code: Select all

<?php
if(whatever condition){
   //some php code here
} else {
?>
...some html here...
<?php
}
?>
is just one way of doing it.

Posted: Sun Mar 28, 2004 8:55 pm
by Deemo
i believe this is one of the "bad habits" that are listed in this forum, but i do it anyway :twisted:

Code: Select all

<?php
if (condition)
{
   //PHP Code
}
else
{
  echo "insert html here";
}
?>