php error with html

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kapturedsoul
Forum Newbie
Posts: 1
Joined: Sun Mar 28, 2004 3:44 pm

php error with html

Post 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!
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post 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.
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post 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";
}
?>
Post Reply