Display image if variable set to true

I’m making a website for a friend and am wondering about the best way to do something.

It’s a flat site and he wants the ability to disable a banner advert without editing all the pages. I thought the best way to do this is have a file somewhere with a variable set to true then have a bit of php in the

on his site that will only display the ad if this variable is set to true.

Am i right in thinking i can put the following in the top of every page

Code:

<?php include_once('ad_switch.php'); ?>

and then something like the following in the div that holds the banner

Code:

<?php if ($adswitch = true) { image goes here ;} ?>

The problem i’m having is that the image is constantly displaying and i can’t get it to bugger off no matter what the $adswitch variable is set to.

Thanks

Can’t you have the adswitch.php define a variable:

[php]
$myAd = “”;
if ($showAd) { $myAd = “Ad Image Here”; }
[/php]

And include it at the top of all your pages:

[php]include_once “adswitch.php”;[/php]

And then use this to insert the advertisements:

[php]

<?php echo $myAd; ?>

[/php]

Stupid thing … ignore the last ?> after the MoreHTML comment.

That’s great, it’s working, just one really lame question. How would one display the actual image rather than the image location.

Thanks

But that’s HTML, not PHP :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service