Jon W
03-19-2009, 12:01 PM
Okay, so I'm making a chat for a game that I'm working on. And well, I'm having a little problem. So what I'm trying to do is if the user_level is 4 the user is a GM if the user_level is 3 the user is a mod.
The problem is that whenever I do this switch statement it seems to be ignoring the user_level. The only result that I seem to get out of this script is
~GM~ Username: and the message
<?php
include("/var/www/connect.php");
$chat = mysql_query("SELECT * FROM chat ORDER BY msg_id limit 50");
$msg = mysql_fetch_array($chat);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<style type="text/css">
body {
background-color:#000000;
margin:0px;
color:#ffffff;
}
</style>
</head>
<body>
<table align="center" cellpadding="0" cellspacing="0">
<?php
switch($msg['user_level']) {
case 3:
while($msg = mysql_fetch_array($chat)) {
echo "<tr>";
echo "<td align=\"left\" valign=\"middle\">~MOD~" . $msg['username'] . ": " . $msg['msg'] . "</tr>";
echo "</tr>";
}
break;
case 4:
while($msg = mysql_fetch_array($chat)) {
echo "<tr>";
echo "<td align=\"left\" valign=\"middle\">~GM~" . $msg['username'] . ": " . $msg['msg'] . "</td>";
echo "</tr>";
}
break;
default:
while($msg = mysql_fetch_array($chat)) {
echo "<tr>";
echo "<td align=\"left\" valign=\"left\">". $msg['username'] . ": " . $msg['msg'] . "</td>";
echo "</tr>";
break;
}
}
?>
</table>
</body>
</html>
So the whole goal is to show their rank. How it works... Or well, it is suppose to work is the user submits their message, along with that message it also gets the user_id that the user is logged in with. Then when it come to the page to show on the screen I want it to sort through the data and if the user_level is 4
~GM~username: And the message
if the user level is 3
~MOD~username: and the message
and if its a normal user then
Username: And the message.
Thanks for the help. :)
Jon W
The problem is that whenever I do this switch statement it seems to be ignoring the user_level. The only result that I seem to get out of this script is
~GM~ Username: and the message
<?php
include("/var/www/connect.php");
$chat = mysql_query("SELECT * FROM chat ORDER BY msg_id limit 50");
$msg = mysql_fetch_array($chat);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<style type="text/css">
body {
background-color:#000000;
margin:0px;
color:#ffffff;
}
</style>
</head>
<body>
<table align="center" cellpadding="0" cellspacing="0">
<?php
switch($msg['user_level']) {
case 3:
while($msg = mysql_fetch_array($chat)) {
echo "<tr>";
echo "<td align=\"left\" valign=\"middle\">~MOD~" . $msg['username'] . ": " . $msg['msg'] . "</tr>";
echo "</tr>";
}
break;
case 4:
while($msg = mysql_fetch_array($chat)) {
echo "<tr>";
echo "<td align=\"left\" valign=\"middle\">~GM~" . $msg['username'] . ": " . $msg['msg'] . "</td>";
echo "</tr>";
}
break;
default:
while($msg = mysql_fetch_array($chat)) {
echo "<tr>";
echo "<td align=\"left\" valign=\"left\">". $msg['username'] . ": " . $msg['msg'] . "</td>";
echo "</tr>";
break;
}
}
?>
</table>
</body>
</html>
So the whole goal is to show their rank. How it works... Or well, it is suppose to work is the user submits their message, along with that message it also gets the user_id that the user is logged in with. Then when it come to the page to show on the screen I want it to sort through the data and if the user_level is 4
~GM~username: And the message
if the user level is 3
~MOD~username: and the message
and if its a normal user then
Username: And the message.
Thanks for the help. :)
Jon W