Jump to content


Photo

Problem


  • Please log in to reply
2 replies to this topic

#1 danmaxito

danmaxito
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 24 April 2006 - 05:52 AM

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


#2 shimano55

shimano55
  • Members
  • Pip
  • Newbie
  • 8 posts
  • LocationLos Angeles, CA

Posted 24 April 2006 - 06:45 AM

Have the links contain the id of the category. For instance:
<a href='articles.php?catId=$cats['id']'>$cats['name']</a>
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:
$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;

Does this help?

-shimano55
PHP is my life.

#3 danmaxito

danmaxito
  • Members
  • PipPip
  • Member
  • 24 posts

Posted 24 April 2006 - 10:11 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users