如何让所有成员的用户名显示为蓝色,而不是用户级别为1的用户?这是我的代码:
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>
';}}}}}
?>
使用该代码我可以为网站管理员http://prntscr.com/gd5s8获取此代码 对于客人或任何其他级别,我得到http://prntscr.com/gd5tf
答案 0 :(得分:1)
扩展Erik在评论中所说的内容:已经 rank0
.. rank5
为font
元素提供的CSS类 1 < / sup>其中一个已经制作rank1
(或者是rank0
?)元素显示为蓝色!
所以改变CSS 应该就足够了:看看CSS是rank1
(或rank0
?)的内容,并使它也适用于其他适用的CSS类。某个地方可能涉及.css文件,找到它(或相应的内联样式元素)是更改其他级别播放器名称的演示文稿中使用的颜色的关键,
1 对弃用的<font>
标记的使用非常有问题(自HTML4.01起,HTML5中不支持已被弃用!) ..但它可能继续作为CSS绑定站点工作。我建议此时将其更改为<span>
(或者删除嵌套元素并直接将类修饰添加到<a>
)。
答案 1 :(得分:1)
在打印用户名之前,您可以使用带有css类的span,以防除1级以外的所有级别 并给出颜色:蓝色到那个班级
例如:
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>';}
并且css将是
.blue
{
color: blue;
}
答案 2 :(得分:1)
据我所知,它是围绕用户名(rank1等)的字体标记上的类,因为它似乎是if语句块中唯一不同的东西。它会根据查看者的用户级别而变化。您可能希望根据$ posts_row的用户级别进行更改。我打赌蓝色风格是基于rank5类,无论是在CSS还是某些javascript中。
如果你想让所有的用户名都是相同的颜色,不管$ posts_row用户的等级如何,我建议删掉if语句,因为它们是冗余的。
答案 3 :(得分:1)
就这样做。它很简单:
$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>";
}
快乐编码:)