ole968 Posted March 24, 2008 Share Posted March 24, 2008 I am working on simple site script with few categories to be displayed on the top of my page as navigation links. Part of the code looks like this: $result = mysql("$DBName","SELECT Name, CatID FROM My_Cats WHERE CatID != '$CatID' ORDER BY CatID") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $ZZName = $row[0]; $ZZCatID = $row[1]; echo "<a href=\"$PHP_SELF?CatID=$ZZCatID\">$ZZName</a>"; } Also in the script, to get Category ID I have: if (!$CatID) { $CatQuery = "CatID LIKE '%%'"; } else { $CatQuery = "CatID = '$CatID'"; } The codes are working fine where it lists all categories as links on the top of the first page (index.php). However, once any one of the categories is clicked on, it will display the correct results on the rest of the page, but also remove that category from the list of links on the top of the index page. I've been trying to get it to not remove the current category but just remove the link from it, leaving the category listed in its own place (just not clickable). If anyone knows what to do, please advise. I will appreciate your help. Thank you Link to comment https://forums.phpfreaks.com/topic/97605-category-display-problem/ Share on other sites More sharing options...
ole968 Posted March 24, 2008 Author Share Posted March 24, 2008 Solved it by removing a part of the first line WHERE CatID != '$CatID' and adding a part if($ZZCatID != $CatID) echo "<a href=\"$PHP_SELF?CatID=$ZZCatID\">$ZZName</a>"; else echo $ZZName; so the code now looks like this $result = mysql("$DBName","SELECT Name, CatID FROM My_Cats ORDER BY CatID") or die(mysql_error()); while ($row = mysql_fetch_row($result)) { $ZZName = $row[0]; $ZZCatID = $row[1]; if($ZZCatID != $CatID) echo "<a href=\"$PHP_SELF?CatID=$ZZCatID\">$ZZName</a>"; else echo $ZZName; } and it works... Link to comment https://forums.phpfreaks.com/topic/97605-category-display-problem/#findComment-499683 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.