Forum Moderators: coopster
I want to modify it so that every second list item uses a stylesheet class that makes its background a darker colour.
Here is the code that produces the list of filenames/links:
$list = "<ul>";
$dir = opendir($absolute_path);
while($file = readdir($dir)) {
if (($file!= "..") and ($file!= ".")) {
$list .= "<li><a href=\"$dl$file\">$file</a></li>";
}
}
$list .= "</ul>";
echo $list;
I want to change this so that every second list item appears as follows:
<li class="darkbg">
Any help would be greatly appreciated!
$cnt = 0;
$list = "<ul>";
$dir = opendir($absolute_path);
while($file = readdir($dir)) {
if (($file!= "..") and ($file!= ".")) {
if ($cnt % 2) $list .= "<li><a href=\"$dl$file\">$file</a></li>";
else $list .= "<li class=\"darkbg\"><a href=\"$dl$file\">$file</a></li>";
$cnt++;
}
}
$list .= "</ul>";
echo $list;