Kaboom Posted December 13, 2009 Share Posted December 13, 2009 So were coding our own forums for a game system we made an we have the users level setup but now I need to make it do user groups. See the groups are defined by numbers: 0 - banned 1 - registered 2 - donator 3 - mod 4 - admin 5 - owner I have this setup to define ranks $rankstring = "<b><font color='#336699'>"; $row=update_lastVisit($_SESSION["user"][0]); $x = 1; while ( $whosonline = mysql_fetch_array( $res ) ) { if ( $x != 1 ) { echo ", "; } echo "<a href=\"member.php?id=$whosonline[id]\">$rankstring$whosonline[name]</b></font></a></strike>"; $x++; } I need to know how to make it MySql read the row for the level and if there in that group then make their name that color. Like for admins something like if user level is 5 then $rankstring = "html code for admin color"; and have that set ONLY admins as that color and not the other groups. How would I do it like that? The row that the usergroups are read from is 5 if that helps. Can someone help quickly? Link to comment https://forums.phpfreaks.com/topic/185008-help-with-usergroups-prolly-really-quick/ Share on other sites More sharing options...
BoarderLine Posted December 13, 2009 Share Posted December 13, 2009 I would suggest setting a $_SESSION var when the user logs in against their user level. if(userlevel=1) { $_SESSION['color']="#000000"; } if(userlevel=2) { $_SESSION['color']="#FFFFFF"; } etc. Then call in within the HTML as:- $color=$_SESSION['color']; $rankstring = "<b><font color='$color'>"; Link to comment https://forums.phpfreaks.com/topic/185008-help-with-usergroups-prolly-really-quick/#findComment-976628 Share on other sites More sharing options...
Andy-H Posted December 13, 2009 Share Posted December 13, 2009 $color = array('#ff0000', '#ffffff', '#119900', '#00ff00', '#0000ff', '#ff00ff'); $color = $color[$variableStoringUserLevel]; $rankstring = '<b><font color="' . $color . '">'; That should work? Link to comment https://forums.phpfreaks.com/topic/185008-help-with-usergroups-prolly-really-quick/#findComment-976636 Share on other sites More sharing options...
Kaboom Posted December 14, 2009 Author Share Posted December 14, 2009 Okay I tried doing $level = $_GET["level"]=clean($_GET["level"]); if ($level = "0") { $rankstring = '<strike><font color="#336699">'; } if ($level = "1") { $rankstring = '<font color="#336699">'; } if ($level = "2") { $rankstring = '<b><font color="red">'; } if ($level = "3") { $rankstring = '<b><font color="#666666">'; } if ($level = "4") { $rankstring = '<b><font color="#336699">'; } if ($level = "5") { $rankstring = '<b><font color="#336699">'; } then print it later but its always printing just the last one for everyone Link to comment https://forums.phpfreaks.com/topic/185008-help-with-usergroups-prolly-really-quick/#findComment-977331 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.