PHP If Query!

Associate
Joined
18 May 2006
Posts
785
OK so I've got a switch working fine and a simple query:

<?php if ($Brand) ?> which will display the code within it if any brand has been entered in the string.. perfect! however I'd like to add in an else show X

for example:

<?php if ($Brand) else echo ('HTML HERE') ?>

but not sure on the correct syntax and can't seem to find it on the net as most examples have if brand echo "code" else echo "code" but I don't need to echo anything for the first instance
 
I am using a switch currently.

I'll try to explain better.


The <?php if ($Brand) ?> is working fine - ie - if no brand is written in the url then it doesnt show any of the code between the <?php if ($Brand) ?> and <?php endif; ?> which is great.

If there is a brand in the url it will show the code so that is all good.

All I need is to be able to say if no brand show this code.

I think what I'm struggling to say is how do I code if no brand show X and hide the code that if brand is linked with brand.
 
the problem with:

<?php
if (condition) { do this... }
else { do this... } ?>

is that I don't want to specify something for the first condition to do as its working fine at the moment - I just need to specify what to show for the else -make sense?
 
The other reason I don't think I can move the if brand into an echo is because there are php tags in what I need it to show like <?php echo $Heading; ?> which will break the code?
 
Thanks I guess I need this at the end also? <?php endelse; ?> actually that doesn't seem correct - how do you end a else?
 
done it I was referencing a part wrong.. just 2 queries.

1, how to I get the php to execute when it comes from a csv file ie
www.'.$brand_to_use.'.net

and can a array have different cases like a switch ie:

$recognised_brands = array(
switch($brand) {
case "apple":
$brandname ='Apple';
$brandurl ='www.apple.co.uk';

would that work?
 
Back
Top Bottom