Reputation: 15
I have some problem getting the user account type from db. I create a column on db called acc_type, it checks if user acc_type is 1 or greater highlight the user name.
I wrote this code but it highlights all the username as red admin.
colors meaning:
Blue = Regular member = 0
Red = admin = 1
Green = Mod = 2
Orange = Super User = 3
Code here
<?php
if($dn5['acc_type'] =='0')
{
echo '<style>
.acc{
color:blue;
}
</style>';
}else if($dn5['acc_type']=='1'){
echo '<style>
.acc{
color:red;
}
</style>';
}else if($dn5['acc_type']=='2'){
echo '<style>
.acc{
color:green;
}
</style>';
}
?>
<span class="acc"><?php echo $username;?></span>
Upvotes: 1
Views: 188
Reputation: 360652
Have you checked what values you're passing into $dn5['acc_type']?
As well, your code is rather repetitive, you could simplify it greatly with something like
switch($dn5['acc_type']) {
case 1: $color = 'red'; break;
case 2: $color = 'green'; break;
default: $color = 'blue';
}
echo "<style>.acc { color: $color; }</style>";
Upvotes: 2