How do i make the username show blue for all the members and just not for users with the user level 1? here is my code:
This is the start of the php
<?php $sql = "SELECT
topic_id,
topic_subject
FROM
topics
WHERE
topics.topic_id = " . mysql_real_escape_string($_GET['id']);
$result = mysql_query($sql);
if(!$result)
{
echo 'The topic could not be displayed, please try again later.';
}
else
{
if(mysql_num_rows($result) == 0)
{
echo 'This topic doesn′t exist.';
}
else
{
while($row = mysql_fetch_assoc($result))
{
//display post data
//fetch the posts from the database
$posts_sql = "SELECT
posts.post_topic,
posts.post_content,
posts.post_date,
posts.post_by,
users.user_id,
users.user_name,
users.avatar,
users.user_date,
users.user_level,
users.forum_rank,
users.site_rank,
users.post,
users.signature
FROM
posts
LEFT JOIN
users
ON
posts.post_by = users.user_id
WHERE
posts.post_topic = " . mysql_real_escape_string($_GET['id']);
$posts_result = mysql_query($posts_sql);
if(!$posts_result)
{
echo '<tr><td>The posts could not be displayed, please try again later.</tr></td></table>';
}
else
{
while($posts_row = mysql_fetch_assoc($posts_result))
{
echo ' <br/>';
echo ' <div class="header" id="post11992">
<div class="reply">
<div class="h3">
<table class="replyheader">
<tr>
<td>
<img src="http://www.naruto-boards.com/images/forum/post_reply.gif" alt="" /> Posted on <b>';
echo '' . date(" F j, Y, g:i A", strtotime($posts_row['post_date'])) . '';echo '</b>
</td>
<td class="right">
<a href="/messages/send/sasy/">Message</a>
<a href="/forums/topic/31/20/quote/11992/#form">Quote</a>
<a href="/forums/topic/31/20/edit/11992/#form">Edit</a>
</td>
</tr>
</table>
</div>
</div>
</div>';
echo '<table class="reply">
<tr>
<td class="post_userinfo">';
///////////webaster
if($_SESSION['user_level'] != 1 )
{
//the user is not an admin
echo '';
}
else
{ echo ' <a href="/index.php?area=profile&username=' . $posts_row['user_name'] . '" class="topicuser_member"><font class="rank5">' . $posts_row['user_name'] . '</font></a>';}
////////////////admin
if($_SESSION['user_level'] != 2 )
{
//the user is not an admin
echo '';
}
else
{ echo ' <a href="/index.php?area=profile&username=' . $posts_row['user_name'] . '" class="topicuser_member"><font class="rank4">' . $posts_row['user_name'] . '</font></a>';}
////////////////GM
if($_SESSION['user_level'] != 3 )
{
//the user is not an admin
echo '';
}
else
{ echo ' <a href="/index.php?area=profile&username=' . $posts_row['user_name'] . '" class="topicuser_member"><font class="rank3">' . $posts_row['user_name'] . '</font></a>';}
////////////////Mod
if($_SESSION['user_level'] != 4 )
{
//the user is not an admin
echo '';
}
else
{ echo ' <a href="/index.php?area=profile&username=' . $posts_row['user_name'] . '" class="topicuser_member"><font class="rank2">' . $posts_row['user_name'] . '</font></a>';}
////////////////Member
if($_SESSION['user_level'] != 5 )
{
//the user is not an admin
echo '';
}
else
{ echo ' <a href="/index.php?area=profile&username=' . $posts_row['user_name'] . '" class="topicuser_member"><font class="rank1">' . $posts_row['user_name'] . '</font></a>';}
////////////////guest
if($_SESSION['user_level'] != 0 )
{
//the user is not an admin
echo '';
}
else
{ echo ' <a href="/index.php?area=profile&username=' . $posts_row['user_name'] . '" class="topicuser_member"><font class="rank0">' . $posts_row['user_name'] . '</font></a>';}
echo'
<br />Rank: ' . $posts_row['site_rank'] . ' <br />Status: <img style="margin-bottom: -6px; margin-top: -2px;" src="/images/other/1.gif" alt="" /> <span class="online">online</span> <br /><img style="min-height: 75px; min-width: 75px; max-height: 75px; max-width: 75px;" src="' . $posts_row['avatar'] . '" alt="" />
<br /><b>Forum Rank:</b><br />' . $posts_row['forum_rank'] . ' <br /><br /><b>Posts:</b> ' . $posts_row['post'] . ' <br /><b>Joined on: </b>
<br />' . date(" F j, Y, g:i A", strtotime($posts_row['user_date'])) . ' </td>
<td>
<div class="post_container">
<div class="right">
<br/>
</div>
<table>
<tr>
<td class="post_text">
' . htmlentities(stripslashes($posts_row['post_content'])) . '
<div class="dots"></div><div class="signature lock300580">' . $posts_row['signature'] . '</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
';}}}}}
?>
With that code i get this for the webmaster http://prntscr.com/gd5s8 With the guest or any other rank, I get this http://prntscr.com/gd5tf
Expanding on what Erik said in a comment: there are already rank0
.. rank5
CSS classes given to the font
elements1 and one of them is already making rank1
(or is it rank0
?) elements appear blue!
So altering the CSS should be sufficient: see what the CSS is for rank1
(or rank0
?) and make it also apply to the other applicable CSS classes. There is likely a .css file involved somewhere, and finding it (or the appropriate inline style element) is key to changing the color used in the presentation of the other level player names,
1 This use of the deprecated <font>
tag is highly .. questionable (it is not supported in HTML5 has been deprecated since HTML4.01!) .. but it may continue to work as a CSS binding site. I would recommend changing it to <span>
at this time (or eliminating the nested element and adding the class decoration directly to the <a>
), however.
you can use a span with a css class before printing username in case of all levels except level 1 and give color : blue to that class
eg:
echo ' <a href="/index.php?area=profile&username=' . $posts_row['user_name'] . '" class="topicuser_member"><font class="rank4"><span class='blue'> . $posts_row['user_name'] . '</span></font></a>';}
and the css would be
.blue
{
color: blue;
}
As far as I can tell, it's the class on the font tag around the username (rank1, etc), since it appears to be the only thing that varies in that block of if statements. It changes based on the user level of the viewer. You probably meant to have it change based on the user level of the $posts_row. I bet the blue style is based on the rank5 class, either in the css or some javascript somewhere.
If you want to make all the usernames the same color, regardless of the rank of the $posts_row user, I would recommend getting rid of the if statements since they would be redundant.
Just do this . Its quite simple :
$username = $post_row['user_name'];
if($_SESSION['user_level'] == 1)
{
echo "<a style='color: blue;' href='index.php?area=profile&username='$username>$username</a>";
}
else
{
echo "<a href='index.php?area=profile&username='$username>$username</a>";
}
Happy Coding :)