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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.