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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<b><u>Administration</u></b>:<!--yay admins!-->
<?php
$level_array = array('6','4'); //levels, add remove and such for your staff userlevel's
$get_admins = mysql_query("SELECT * FROM `members` WHERE `userlevel` = '$level_array[0]';"); //get all your admins
echo "<ul>"; //lets make a neat list
while($admins = mysql_fetch_array($get_admins)){ //make a loop
echo "<li><a href='members.php?user=$admins[username]'>$admins[username]</a></li>"; //echo the admin with am link to profile.
} //end our loop for admins
echo "</ul>"; //end list
?>
<b><u>Moderation</u></b>:<Br /><!--Mods =P-->
<?php
$get_mods = mysql_query("SELECT * FROM `members` WHERE `userlevel` = '$levels_array[1]';");
echo "<ul>"; //lets make another neat list
while($mods = mysql_fetch_array($get_mods)){ //make a new loop
echo "<li><a href='members.php?user=$admins[username]'>$admins[username]</a></li>"; //echo the mods with am link to profile.
} //end our loop for mods
echo "</ul>"; //end list
?>
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
<?php
function color($rcolor){//start function to color userlevels
$rank = array('0','1','2','3','4','5','6'); //basic levels 1-6 not all used i'm pretty sure :P but never know
$color = array('#0000FF','#000000','#FF0000','#9932CC','#00CC00','#F0F0F0','#00FF00'); //all your colors for each of the user levels
return str_replace($rank, $color, $rcolor); //replace level with color then return the color instead of level :P
} //end function
?>
Could turn the original staff page into something like the following in which i use on my website..
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
echo "<b><u>Administration</u></b>:<Br />"; //admin administration same thing pretty much
$getadmins = mysql_query("SELECT * FROM `members` WHERE `userlevel` = '6' ORDER BY `id` ASC"); //get admins order by ID
if(mysql_num_rows($getadmins) == '0'){ //no admins?!?!
echo "There Are No Admins On YourSite.com"; //no admins :)
}else{ //maybe..
while($radmin = mysql_fetch_array($getadmins)){ //make our loop.
echo "<a href=\"members.php?user=$radmin[username]\"><font color=\"".color($radmin[userlevel])."\">$radmin[username]</font></a>"; //send link with colored name :)
} //end loop
} //end no admin check :)
echo "<b><u>Moderation</u></b>:<Br />"; //start moderators
$getmods = mysql_query("SELECT * FROM `members` WHERE `userlevel` = '4' ORDER BY `id` ASC"); //get all admins by ID
if($mysql_num_rows($getmods) == '0'){ //check for mods
echo "There Are No Mods On YourSite.com"; //if none
}else{ //maybe there is some!!!
while($rmod = $MySql->fetchArray($getmods)){ //yup, start loop
echo "<a href=\"members.php?user=$rmod[username]\"><font color=\"".color($rmod[userlevel])."\">$rmod[username]</font></a>"; //link, color and such from before :)
} //end our loop
} //end the mod check.
/*
Thats All Folks!
*/
?>
Yet again not that bad of a code yet you can see the difference with a bit more time and all that happy stuff.