Jump to content

Recommended Posts

Hey everyone! I was looking for a place on the net to get help with PHP, and I found this site, so I hope I'm posting this in the right place.

 

Right, down to business!

 

On a menu on my site (which is a text based game), I want a menu item to display only when a user has reached a certain level of technology.

 

I have a snippit of code that was in the stock code that only displays item when in a clan

 

<?=($userinf['clan']?"- <a href=\"cforum.php\">Clan forum</a><br>\n":"");?>

 

$userinf is refering to a table on my database, and clan is a field... I want to say that when the field 'b_espi' is equal to or greater than 3 then it shows it!

 

Also, how can I modify this snip from cforum.php to do the same thing as I kinda want to do above?

 

if(!$userinf['clan']) { header("Location: member.php"); die(); }

 

Thanks...

 

Once again, I hope I'm doing this the right way!

First the short tags <?= are not recommended instead use the full <?php tag.

 

For bluesouls version to work it would actually need to be

 

<?php echo isset($userinf['clan'])?"- <a href=\"cforum.php\">Clan forum</a><br>\n":"";?>

 

Now to have that menu item displayed it would be like

 

<?php echo ($userinf['level'] > 100)?"- <a href=\"extraitem.php\">Extra Menu Item</a><br>\n":"";?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.