LexHammer Posted November 26, 2009 Share Posted November 26, 2009 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 *} Quote Link to comment https://forums.phpfreaks.com/topic/183003-show-table-only-if/ Share on other sites More sharing options...
garethhall Posted November 26, 2009 Share Posted November 26, 2009 Maybe this <?php if(user_level_id <= "3"){?> <table > tr and td's here </table> <?php }?> Quote Link to comment https://forums.phpfreaks.com/topic/183003-show-table-only-if/#findComment-965889 Share on other sites More sharing options...
LexHammer Posted November 26, 2009 Author Share Posted November 26, 2009 Forgot to say that this is the code from the tpl file and i cant put php in it . I can put the php code in the php file of the page where this tables shows... So i need clear php code. Quote Link to comment https://forums.phpfreaks.com/topic/183003-show-table-only-if/#findComment-965895 Share on other sites More sharing options...
garethhall Posted November 26, 2009 Share Posted November 26, 2009 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(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/183003-show-table-only-if/#findComment-965899 Share on other sites More sharing options...
LexHammer Posted November 26, 2009 Author Share Posted November 26, 2009 Sorry, but when i crated this topic, i realized that i will need php to do what i wanted, and this is tpl code. I will just make it show another picture if the user is not on that levels. Thank you anyway for you help! Quote Link to comment https://forums.phpfreaks.com/topic/183003-show-table-only-if/#findComment-965906 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.