Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

some help with an if statement please


Aspen_AGB

Recommended Posts

Posted

I am setting it up so it will desplay some extra navagational features in the header while signed in, and when they arn't there will be an alternative bunch of buttons... but I'm definitly not a php guru... you probably dont need to be anyways for this.. but I still need help :oops:

 

the closest I've got to it is this:

 

<?php if (tep_session_is_registered('customer_id')) { 



<a href="http://link"><img src="button1.jpg"></a>



} else {



<a href="http://link2"><img src="button2.jpg"></a>



?>

 

Although to me it looks fine and dandy, it dosen't work :(

 

 

I'd greatly appreciate any guidance at all :D

Posted

I think it needs to be changed to

<?php if (tep_session_is_registered('customer_id')) { 



echo '<a href="http://link"><img src="button1.jpg"></a>' . "n";



} else {



echo '<a href="http://link2"><img src="button2.jpg"></a>' . "n";



}

?>

or

<?php echo tep_session_is_registered('customer_id')

? '<a href="http://link"><img src="button1.jpg"></a>'

: '<a href="http://link2"><img src="button2.jpg"></a>';

?>

 

The . "n" on the end of the line is optional but makes the resulting html look better in view source. You seem to be missing the closing } in your else section. The ? : combination is sort of an inline if then else.

In olden times the men were made of iron and the ships were made of wood; now it's the other way around. :wink:

Posted

Thank you! :D

 

I tried it and it works, your the best! i couldn't get this silly thing to work and now its all nice and spiffy 8)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...