Jump to content

Show table only if...


LexHammer

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

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.