Jump to content

Problem


danmaxito

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
Link to comment
https://forums.phpfreaks.com/topic/8233-problem/
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
Link to comment
https://forums.phpfreaks.com/topic/8233-problem/#findComment-29997
Share on other sites

Archived

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

×
×
  • Create New...

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.