Tutorial :CSS and SQL populated lists



Question:

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:
http://i37.tinypic.com/28hfpzm.jpg

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?


Solution:1

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>';  }  

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »