PHP-高亮度选定链接

PHP-高亮度选定链接,php,css,hyperlink,highlighting,Php,Css,Hyperlink,Highlighting,如何“突出显示”(使用不同的颜色、加粗等)已单击的链接 例如: 尝试让右侧边栏中的“今日”、“周”和“月”链接在单击后变成不同的颜色 下面是我用来在右侧边栏中显示结果的代码: <div id="sidebar"> <div class="post"> <h2> <font color="#333333">Top 50 Celebrities</font> <br> <br> <font color="#

如何“突出显示”(使用不同的颜色、加粗等)已单击的链接

例如: 尝试让右侧边栏中的“今日”、“周”和“月”链接在单击后变成不同的颜色

下面是我用来在右侧边栏中显示结果的代码:

<div id="sidebar">

<div class="post">
<h2>

<font color="#333333">Top 50 Celebrities</font>
<br>
<br>
<font color="#333333"><a href="index.php?table=today">Today</a></font>
<font color="#333333"><a href="index.php?table=week">Week</a></font>
<font color="#333333"><a href="index.php?table=month">Month</a></font>
</font>
<br>
<br>

<?php

function showTable ($table){

if (!in_array($table, array('today', 'week', 'month'))) {
  return false;
}

global $wpdb;
$result = $wpdb->get_results('SELECT name, count FROM wp_celebcount_' . $table);
foreach($result as $row) {
echo '<a href="http://www.celebrything.com/?s=' .
    urlencode($row->name) . '&search=Search">' . $row->name .
    '</a> - ' . $row->count . ' Posts<br/>';
}
}


if (!empty($_GET['table'])) {
showTable($_GET['table']);

} else { showTable('today'); }

?>




</h2>
</div>

</div>

<div class="clear"></div>

前50名名人




CSS可以做到这一点

如果在任何时候访问了链接:

<style type="text/css">
a:visited { color: red; }
</style>
注意:IE7和更低版本不支持
:focus
。请参阅和。

CSS可以做到这一点

如果在任何时候访问了链接:

<style type="text/css">
a:visited { color: red; }
</style>

注意:IE7和更低版本不支持
:focus
。请参阅和。

如果您询问如何激活当前页面,请参阅以下方法:

<font color="#333333"><a class="<?php echo currentPage('today') ?>" href="index.php?table=today">Today</a></font>
<font color="#333333"><a class="<?php echo currentPage('week') ?>" href="index.php?table=week">Week</a></font>
<font color="#333333"><a class="<?php echo currentPage('month') ?>"href="index.php?table=month">Month</a></font>


function currentPage($isTableSet)
{
    if($_GET['table'] == $isTableSet)
        return 'selected'
    else
        return '';
}

函数currentPage($isTableSet)
{
如果($\u GET['table']==$isTableSet)
返回“选定”
其他的
返回“”;
}
您需要在css中添加.selected类,并将其设置为您想要的样式,例如:

<style type="text/css">
    .selected  {
        font-weight: bold;
    }
</style>

.选定{
字体大小:粗体;
}

如果您询问如何激活当前页面,以下是您的方法:

<font color="#333333"><a class="<?php echo currentPage('today') ?>" href="index.php?table=today">Today</a></font>
<font color="#333333"><a class="<?php echo currentPage('week') ?>" href="index.php?table=week">Week</a></font>
<font color="#333333"><a class="<?php echo currentPage('month') ?>"href="index.php?table=month">Month</a></font>


function currentPage($isTableSet)
{
    if($_GET['table'] == $isTableSet)
        return 'selected'
    else
        return '';
}

函数currentPage($isTableSet)
{
如果($\u GET['table']==$isTableSet)
返回“选定”
其他的
返回“”;
}
您需要在css中添加.selected类,并将其设置为您想要的样式,例如:

<style type="text/css">
    .selected  {
        font-weight: bold;
    }
</style>

.选定{
字体大小:粗体;
}