Jump to content

Recommended Posts

Hello, I have this table, which shows user levels with picture. How to make this table appear only if the user is level 1,2 or 3. and not to show if the user is on another level? As it is now, if the user is on another level, the table is there empty, only with the header and its... ugly :) Thank you!

 

{* DISPLAY USER LEVEL *}
<table cellpadding='0' cellspacing='0' width='100%' style='margin-bottom: 10px;'>
<tr>
<td class='header'>User Level</td>
<tr>
<td class='profile'>
{if $owner->user_info.user_level_id == 1}
<img src="../images/nophoto.gif" border="0" />
{/if}
{if $owner->user_info.user_level_id == 2}
<img src="../images/newupdates.gif" />
{/if}
{if $owner->user_info.user_level_id == 3}
<img src="../images/search.gif" />
{/if}
</td>
</tr>
</table>
{* END USER LEVEL *}

Link to comment
https://forums.phpfreaks.com/topic/183003-show-table-only-if/
Share on other sites

Ok So lets try this. Note you may need to make some variable global or pass them into the function.

 

<?php
function showLevel(){
{* DISPLAY USER LEVEL *}
<table cellpadding='0' cellspacing='0' width='100%' style='margin-bottom: 10px;'>
<tr>
<td class='header'>User Level</td>
<tr>
<td class='profile'>
{if $owner->user_info.user_level_id == 1}
<img src="../images/nophoto.gif" border="0" />
{/if}
{if $owner->user_info.user_level_id == 2}
<img src="../images/newupdates.gif" />
{/if}
{if $owner->user_info.user_level_id == 3}
<img src="../images/search.gif" />
{/if}
</td>
</tr>
</table>
{* END USER LEVEL *}
}

if(user_level_id <= "3"){
showLevel();
}
?>

Link to comment
https://forums.phpfreaks.com/topic/183003-show-table-only-if/#findComment-965899
Share on other sites

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.