One more thing:
Personally, I also think it's best to use a numeric id for your user levels. Add a new table, user_levels, to your database. The table will just be a unique ID field and a text description.
The user level stored in the users table will be the numeric ID, not the text. This is called "normalizing" your database, which in the long run increases efficiency and decreases storage space.
Take, for example, a users table with 5 administrators. Your database table takes up at least 13 bytes for each user to store the text "administrator" in the user levels, a total of 65 bytes. Compare that to the 5 bytes it would take to store a 1-byte integer that matches the numeric ID of the user_levels table.
This is how it'd all break down:
Code:
table: user_levels
id desc
1 basic user
2 moderator
3 administrator
...
table: users
id username user_level_id
1 nikolai 1
2 dazednconfused 3
...
Now, your query will be something:
Code:
$query = "SELECT desc from user_levels
INNER JOIN users ON
user_levels.id = users.user_level_id
AND users.username = $username";
If you're not comfortable using JOINs, use this equivalent query:
Code:
$query = "SELECT user_levels.desc from users, user_levels
WHERE users.username = $username
AND users.user_level_id = user_levels.id";
Make sense?
There's lots of information and tutorials out there about efficient database design, normalization, joins, etc. Happy hunting!
Take care,
Nik
http://www.bigaction.org/