开发者

CSS and SQL populated lists

I'm 开发者_如何学运维planning on doing this, but I can't get my head around to if this is completely possible or not.

I'm trying to follow this design:

CSS and SQL populated lists

The list on the left is populated by SQL. When clicking on one of these links on the left, the page will change (i.e. something like designers.php?designerID=whatever).

All this I can do easily, but I'm looking more at the CSS coding. You see when I click on a link, it covers in a purple box to show you've selected it (You can see in the image that Helen Mary is selected). I can do this in an non SQL list, but how would I do this WITH an SQL populated list?


When you display your list you know your parameters and the current parameter too. All you need is to mark the current li with a custom class like current then set it's background color in CSS.

<?php

foreach($nav as $key => $label)
{
    $class = $key == $_GET['designerID'] ? 'current' : 'normal';
    print '<li class="' . $class . '">' . $label . </li>';
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜