PDA

View Full Version : Need Help with DJ Panel.



koolkid
13-09-2008, 11:15 AM
Hey guys,

Right ok what i need is the code strips in "The Housekeeping Guy" panel for:

DJs: ( Shows number of DJ's in the panel )
Your Level ( Shows the user level )
Logged in as: ( Shows the username )

If you could help me out that would be fantastic!

Thanks,
Josh.

Calon
13-09-2008, 01:34 PM
Hey guys,

Right ok what i need is the code strips in "The Housekeeping Guy" panel for:

DJs: ( Shows number of DJ's in the panel )
Your Level ( Shows the user level )
Logged in as: ( Shows the username )

If you could help me out that would be fantastic!

Thanks,
Josh.



<?php
$shortname = $_SESSION['session_username'];
$query-for-djs = mysql_query( "SELECT * FROM `staff` WHERE username = '$shortname'" );
$number-of-djs = mysql_num_rows($query-for-djs);

$object = mysql_fetch_object($query-for-djs);

echo $number-of-djs;
echo $shortname;
echo $object->level;
?>

Not sure if it works, but I think that's the old database structure from the old Housekeeping, hopefully it works. :P I grabbed the session var from guy's panel, if it doesn't work I'll try again and get other things from the panel.

MrCraig
13-09-2008, 03:09 PM
i dont think that will work :S

the "for" is a reserved command and i dont think it can be used in variables..
Correct me if im wrong though.

iUnknown
13-09-2008, 03:57 PM
<?php
$shortname = $_SESSION['session_username'];
$query-for-djs = mysql_query( "SELECT * FROM `staff` WHERE username = '$shortname'" );
$number-of-djs = mysql_num_rows($query-for-djs);

$object = mysql_fetch_object($query-for-djs);

echo $number-of-djs;
echo $shortname;
echo $object->level;
?>
Not sure if it works, but I think that's the old database structure from the old Housekeeping, hopefully it works. :P I grabbed the session var from guy's panel, if it doesn't work I'll try again and get other things from the panel.


<?php
$shortname = $_SESSION['session_username'];
if($_SESSION['session_level'] == "1") {
$level = "Admin";
}
else {
$level = "DJ";
}
$querydjs = mysql_query( "SELECT * FROM `staff`" );
$numberofdjs = mysql_num_rows($querydjs);

echo 'DJs: ' . $numberofdjs . '';
echo 'Your Level: ' . $level . '';
echo 'Logged in as: ' . $shortname . '';
?>Should work?

Excellent2
13-09-2008, 04:00 PM
Would work but why don't you just echo the session level?
$_SESSION['session_level']?

Jackboy
13-09-2008, 04:03 PM
Would work but why don't you just echo the session level?
$_SESSION['session_level']?

Because the user could be promoted/demoted whilst logged in.

I think its bad to set username and details as sessions because if the user changes them it will have the wrong session.

I think its best to get stuff from table with id, as that is extremely unlikely to change ;P

Calon
13-09-2008, 04:03 PM
i dont think that will work :S

the "for" is a reserved command and i dont think it can be used in variables..
Correct me if im wrong though.
Ah, your right. ;D

iUnknown
13-09-2008, 05:17 PM
Would work but why don't you just echo the session level?
$_SESSION['session_level']?

Because the session level is either 1 or 0. I'm not silly enough to not realise I could do that if I could... :)


Because the user could be promoted/demoted whilst logged in.

I think its bad to set username and details as sessions because if the user changes them it will have the wrong session.

I think its best to get stuff from table with id, as that is extremely unlikely to change ;P

It's based off the original housekeeping, that's how it was done. I only tweaked things like that slightly to make it more secure.

Want to hide these adverts? Register an account for free!