Forum Moderators: coopster

Message Too Old, No Replies

Dis/Enable content via PHP between PHP syntax on condition.

If condition=true render, else do not render this portion (between PHP)

         

JAB Creations

6:04 pm on Jan 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I need to serve content between separate PHP syntax areas only when certain conditions are met.

<?php
if () {}?>
<p>conditional content here</p>
<?php?>

So the content that should only be served when a condition is met is not inside PHP syntax, but between it.

I have no clue if this can be done or if it can how to go about it.

John

appi2

6:08 pm on Jan 18, 2006 (gmt 0)

10+ Year Member



dont undersatnd the question so ill do this.
<?php
if () {}?>
<p><?php echo "conditional content here";?></p>
<?php?>

or

<?php
if () {}?>
<p><?php include("pathtofile/file.php");?></p>
<?php?>

jatar_k

6:26 pm on Jan 18, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the way to do it is like so

<?php
if (mycondition) {?>
<p>conditional content here</p>
<?php }?>

that way if mycondition is met the content is delivered

if not, it never appears

JAB Creations

6:42 pm on Jan 18, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Jatar, thank you! Absolutely exactly what I needed!

A big thanks to both of you for replying (especially so quickly)!

John