Simple Staff Page


Been a while since i've written a tutorial so i thought i would i would make one for showing staff members.

User levels:
Admin - 6
Moderator - 4 (Just for say edit if you want)

Files Affected
staff.php - Needs To Be Created.

Filling up staff.php:

PHP Code
  1. <b><u>Administration</u></b>:<!--yay admins!-->
  2. <?php
  3. $level_array = array('6','4'); //levels, add remove and such for your staff userlevel's
  4. $get_admins = mysql_query("SELECT * FROM `members` WHERE `userlevel` = '$level_array[0]';"); //get all your admins
  5. echo "<ul>"; //lets make a neat list
  6. while($admins = mysql_fetch_array($get_admins)){ //make a loop
  7. echo "<li><a href='members.php?user=$admins[username]'>$admins[username]</a></li>"; //echo the admin with am link to profile.
  8. } //end our loop for admins
  9. echo "</ul>"; //end list
  10. ?>
  11. <b><u>Moderation</u></b>:<Br /><!--Mods =P-->
  12. <?php
  13. $get_mods = mysql_query("SELECT * FROM `members` WHERE `userlevel` = '$levels_array[1]';");
  14. echo "<ul>"; //lets make another neat list
  15. while($mods = mysql_fetch_array($get_mods)){ //make a new loop
  16. echo "<li><a href='members.php?user=$admins[username]'>$admins[username]</a></li>"; //echo the mods with am link to profile.
  17. } //end our loop for mods
  18. echo "</ul>"; //end list
  19. ?>


Not too long to do, not too easy not to hard. You could add user coloring with a simple function like BBCode such as:

PHP Code
  1. <?php
  2. function color($rcolor){//start function to color userlevels
  3. $rank = array('0','1','2','3','4','5','6'); //basic levels 1-6 not all used i'm pretty sure :P but never know
  4. $color = array('#0000FF','#000000','#FF0000','#9932CC','#00CC00','#F0F0F0','#00FF00'); //all your colors for each of the user levels
  5. return str_replace($rank, $color, $rcolor); //replace level with color then return the color instead of level :P
  6. } //end function
  7. ?>


Could turn the original staff page into something like the following in which i use on my website..

PHP Code
  1. <?php
  2. echo "<b><u>Administration</u></b>:<Br />"; //admin administration same thing pretty much
  3. $getadmins = mysql_query("SELECT * FROM `members` WHERE `userlevel` = '6' ORDER BY `id` ASC"); //get admins order by ID
  4. if(mysql_num_rows($getadmins) == '0'){ //no admins?!?!
  5. echo "There Are No Admins On YourSite.com"; //no admins :)
  6. }else{ //maybe..
  7. while($radmin = mysql_fetch_array($getadmins)){ //make our loop.
  8. echo "<a href=\"members.php?user=$radmin[username]\"><font color=\"".color($radmin[userlevel])."\">$radmin[username]</font></a>"; //send link with colored name :)
  9. } //end loop
  10. } //end no admin check :)
  11. echo "<b><u>Moderation</u></b>:<Br />"; //start moderators
  12. $getmods = mysql_query("SELECT * FROM `members` WHERE `userlevel` = '4' ORDER BY `id` ASC"); //get all admins by ID
  13. if($mysql_num_rows($getmods) == '0'){ //check for mods
  14. echo "There Are No Mods On YourSite.com"; //if none
  15. }else{ //maybe there is some!!!
  16. while($rmod = $MySql->fetchArray($getmods)){ //yup, start loop
  17. echo "<a href=\"members.php?user=$rmod[username]\"><font color=\"".color($rmod[userlevel])."\">$rmod[username]</font></a>"; //link, color and such from before :)
  18. } //end our loop
  19. } //end the mod check.
  20. /*
  21. Thats All Folks!
  22. */
  23. ?>


Yet again not that bad of a code yet you can see the difference with a bit more time and all that happy stuff.
ShadowMage's Avatar
Author:
Views:
3,670
Rating:
Posted on Tuesday 8th April 2008 at 05:53 PM
Dalez
Dalez's Avatar
Also, how would i make it so i can have bold or underlined in my BB code?
Posted on Tuesday 8th April 2008 at 05:48 PM
Dalez
Dalez's Avatar
Well i got it to work :P

I have used yours.. and i have used the BB code too.
this is an error i get:

Fatal error: Function name must be a string in /home/a8067842/public_html/user/pages/staff.php on line 14

How do i fix it?
Posted on Monday 24th March 2008 at 03:03 PM
Dalez
Dalez's Avatar
How would i get MODS to show if i edited the MOD level to 2? I got the admin one to work, but MOD won't :S
Posted on Tuesday 27th November 2007 at 05:50 PM
ShadowMage
ShadowMage's Avatar
i was bored last night so i went through some old script directories i had found and decided to comment some and post =P
Posted on Tuesday 27th November 2007 at 05:13 PM
DanielXP
DanielXP's Avatar
Nice tutorial!