Hi All,
I have a snippet of code (below) which I use to create a dynamic menu from a MySQL database for a community website. Main fields used in the database are:
ID
parent (what the parent page is)
page_order (what is says on the tin)
short_title (a short title for the page for the URL)
title (the page title - used as the text for the link)
content (the content for the page)
I have got the dynamic list to display fine, but what I would like to be able to do is give each list item a 'class' tag when it has been selected (and thus is the page being shown). Can anyone suggest how to amend the below code to allow this?
Code is (edit - slightly modified now):
<!-- ##### START LIST_INFO_PAGES ##### -->
<?php
include("../config/config.php");
?>
<?php
$sql = "SELECT * FROM `PCNET_$filename` WHERE parent = 'council' AND type = 'Pages' ORDER BY page_order ASC";
$sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql);
while ($row = mysql_fetch_assoc($sql_result)) {
print '';
if ($category == '$name') {
echo '<li><a href="../council-indiv.php?id=';
echo ($row["id"]).'&name=';
echo nl2br(stripslashes(utf8_decode($row["category"]))).'" title="';
echo nl2br(stripslashes(utf8_decode($row["title"]))).'" class="selected">';
echo nl2br(stripslashes(utf8_decode($row["category"]))).'</a></li>';
}
else {
echo '<li><a href="../council-indiv.php?id=';
echo ($row["id"]).'&name=';
echo nl2br(stripslashes(utf8_decode($row["category"]))).'" title="';
echo nl2br(stripslashes(utf8_decode($row["title"]))).'">';
echo nl2br(stripslashes(utf8_decode($row["category"]))).'</a></li>';
}
};
?>
<!-- ##### END LIST_INFO_PAGES ##### -->
I just can't get this to work, and any help would be really gratefully received.