Jump to content

[SOLVED] Need help with using PHP with my Mysql Database


bobsmith20

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":"";?>

Archived

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

×
×
  • 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.