I'm trying to display a link orange when clicked but for some reason I can get it to work when using PHP can some one help me correct this problem?
Here is the PHP code.
function category_tree( $parent = 0, $parent_url = '' ){
$page_url = current_page_url();//grabs url address
echo "<ol>";
$mysqli = mysqli_connect("localhost", "root", "", "sitename");
$q = sprintf("SELECT id, category, url FROM categories WHERE parent_id = %d ORDER BY category asc", $parent);
$r = mysqli_query($mysqli, $q);
while($rs = mysqli_fetch_assoc($r) ){
$url = $parent_url . $rs['url'];
echo '<li> <a href="' . $url . '" title="' . $rs['category'] . ' Category Link" ';
if($url == $page_url){
echo 'style="color: orange;"';
}
echo '>' . $rs['category'] . '</a> </li>';
category_tree($rs['id'], $url);
}
mysqli_free_result( $r );
echo "</ol>";
}
Output:
Arts & Humanities
Autos
Business
Computers & Technology
Creative Writing
Education
Entertainment