Category display problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ole968
Forum Newbie
Posts: 2
Joined: Mon Mar 24, 2008 11:39 am

Category display problem

Post by ole968 »

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:

Code: Select all

 
 
$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:

Code: Select all

 
 
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
ole968
Forum Newbie
Posts: 2
Joined: Mon Mar 24, 2008 11:39 am

Re: Category display problem

Post by ole968 »

Solved it by removing string from the first line and adding if...

Code: Select all

$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; 
        }
Post Reply