Jump to content

Archived

This topic is now archived and is closed to further replies.

danmaxito

Problem

Recommended Posts

Hello,

Lets see if I can explain this one...

Here goes...

OK, I have a page that lists several categories (from a MySQL DB). When you click on one of the categories, you see a list of articles that pertain to that category. This is all connected with: cat_Id, cid, and art_Id.

Here is what I am trying to do: Once you click on one of the categories, I want the new page that loads with the list of articles, to display what category the viewer is currently in.
IN OTHER WORDS... For example: I will go to the site, click on a category, and on the new page that loads, I will see a line of text the says "You are currently in the *cat_name* category section", then I will see a list of articles.

What code should I use to get the category's name?

Thanks a million!!!!

Danmaxito

Share this post


Link to post
Share on other sites
Have the links contain the id of the category. For instance:
[code]<a href='articles.php?catId=$cats['id']'>$cats['name']</a>[/code]
have $cats be an array with the DB fields and values by using a while loop in conjunction with mysql_fetch_assoc();

Then on articles.php:
[code]$catId = $_REQUEST['catId'];
$q = mysql_query("SELECT * FROM cats WHERE id='$catId' LIMIT 1");
$cat = mysql_fetch_assoc($q);
echo "You are currently viewing ".$cat;[/code]

Does this help?

-shimano55

Share this post


Link to post
Share on other sites
THANK YOU VERY MUCH!

The information you gave me sure did help. I even was abe to put extra features on the page. Thanks again :)


Danmaxito

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.