Forgot Password / Register
Site Statistics
Total Members: 509
Total Tutorials: 242
Newsest User: Lestop
Todays Unique Hits: 92
0 Users 2 Guests Online

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
1
2
3
4
5
6
7
8
<?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.
ShadowMage
Author:
Views:
1693
Rating:
Posted on Tuesday 8th April 2008 at 05:53 PM
Dalez
Dalez
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
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
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
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
Nice tutorial!