if function in php ( combine php and html)

Discussing Html . Code , Software , other

Moderators: macek, egami, gesf

bashebashe
New php-forum User
New php-forum User
Posts: 1
Joined: Sun Sep 19, 2010 8:45 pm

if function in php ( combine php and html)

Postby bashebashe » Sun Sep 19, 2010 8:54 pm

hi to all,

I wanted to combine if function(php) with html as i say below:

e.g.

<?php if(Statement) ?>
Action1
<?php else ?>
Action2
<?php ; ?>

means if 'Statement' is done, Action1 will happen , else Action2 will happen, which both of Action1 and Action2 are html codes,
can anyone tell me how to change the code , so the code will have this property??

Regards, :)

User avatar
macek
php-forum Active User
php-forum Active User
Posts: 277
Joined: Wed Aug 25, 2010 10:42 am
Contact:

Re: if function in php ( combine php and html)

Postby macek » Sun Sep 19, 2010 9:15 pm

Code: Select all

<?php

if(Statement) {

  echo 'SOME <b>HTML</b>';

} else {

  echo 'ANY OTHER </b>HTML</b>';

}

?>

perseadrian
New php-forum User
New php-forum User
Posts: 1
Joined: Sun Oct 03, 2010 5:32 am

Re: if function in php ( combine php and html)

Postby perseadrian » Sun Oct 03, 2010 5:46 am

<?php if(Statement) { ?>
<b>Some HTML</b>
<?php } else { ?>
<b>Other HTML</b>
<?php } ?>


Return to “HTML Basics”

Who is online

Users browsing this forum: No registered users and 1 guest

cron