Jump to content

Recommended Posts

Hi Guys,

 

on a users profile page i was going to add an edit post button (only for moderator and above to see) if the users class isn't mod or admin then echo no edit button, but it isn't going to plan

 

heres my coding:

 

     while ($row_display = mysql_fetch_array($result5)) {
     
     $post_id = $row_display['id'];
     $user_id = $row_display['user_id'];
     $user_comments = $row_display['comment'];
     $post_date = $row_display['date_added'];
     
     // get the usernames and links...///////////////////////////////////////////////////
     $query6 = "SELECT * FROM `membership` WHERE `id`='$user_id'";
     $result6 = mysql_query($query6);     
     $row = mysql_fetch_array($result6);
     
     $poster_id = $row['id'];
     $poster_name = $row['username'];
     $poster_avatar = $row['avatar'];
     $poster_class = $row['user_class'];
     
     // start making a table:)...////////////////////////////////////////////////////////
     echo '<table width="500" border="1" bordercolor="#000000" cellspacing="2" cellpadding="2" />
           <tr>
           <td colspan="2" align="left" /> <a href="user_details.php?id='.$poster_id.'" />'.$poster_name.'</a> - (<b>'.$poster_class.'</b>) - <font size="1" />Posted On: '.$post_date.'</font> ';
           
           // if the user class fits echo edit button etc.../////////////////////////////
           
           if($poster_class != "Moderator" && $poster_class != "Administrator") {
           

           echo "Can't Edit Wrong UserClass!";
      
           
     ####################     
     } else {
     ####################      

           echo "<font size=\"1\">[<a href=\"mod_edit_comments.php?id=$post_id\"/><font color=\"red\" />EDIT</font></a>]";

              
     }
     
     echo ' </td>
            </tr>
            <tr>
            <td width="150" align="center" /><img src="avatars/'.$poster_avatar.'" /></td><td width="350" align="left" valign="top"/>'.$user_comments.'</td>
            </tr><br />';
     
     }  
               
     echo '</table><br />';
     
     } else {
                         
        echo "<b>No Comments Have Been Added Yet!</b><br /><br />";
        
     
     }

 

thanks for any help guys

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/52407-solved-getting-user-class/
Share on other sites

if($poster_class != "Moderator" && $poster_class != "Administrator") {

 

Think about that logic for a moment. If I'm a moderator it will fail because I'm not also an admin and vice versa.

 

What you want is if I'm a moderator OR an administrator then show the edit link.

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.