We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,629 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Tag archive page

Hello,

I'm making a tagging system for a script. The tagging system is much like the one here.
be it's not normalized like this one.

It's a single table in my database with three columns.

uid | id | name

The 'id' field is not auto increment. It is a field which holds the corresponding tables unique id.

Everything works well. I explode before it hits the database, I get the unique id with mysql_insert_id. No users and just one admin so this won't be any issue.

My question is.. How do I make it so one can click the tag and it will take you to a url like.. tags.php?=programming or something to that effect?

This query gets all tags with the tag name being $tagname . This works if I display it on a test page. and exchange the tagname var with an actual tag name like "bookreviews' or what not.

$query = "SELECT titles.title,tags.id FROM titles,tags WHERE tags.tag = '$tagname' AND tags.id = titles.id GROUP BY tags.id";

I don't want to have to have individual pages for my tags. At the moment I can do that. But I think the idea is to have a tags.php archive that does it for you..

Thanks.

2
Contributors
4
Replies
16 Hours
Discussion Span
2 Years Ago
Last Updated
5
Views
Question
Answered
reco21
Light Poster
43 posts since Jan 2011
Reputation Points: 14
Solved Threads: 1
Skill Endorsements: 0

I think you answered your own question already. A tags.php file should work just fine. You can get the tag through the URL. So, just make your tags clickable with an A tag, and point it to the tags.php?tag=bookreview

pritaeas
Posting Prodigy
Moderator
9,549 posts since Jul 2006
Reputation Points: 1,194
Solved Threads: 1,497
Skill Endorsements: 98

Yeah. I don't have the slightest how I would make a tags page though. I guess I would put it in a foreach statement.. I am not sure how to do this.

reco21
Light Poster
43 posts since Jan 2011
Reputation Points: 14
Solved Threads: 1
Skill Endorsements: 0

Problably something like:

$tag = $_GET['tag']; // tags.php?tag=php
$query = "SELECT * FROM tags WHERE name='$tag'"; // slightly different, you know what should be here
$result = mysql_query($query);
if ($result)
{
  while ($row = mysql_fetch_assoc($result))
  {
    // output your data here.
  }
}
pritaeas
Posting Prodigy
Moderator
9,549 posts since Jul 2006
Reputation Points: 1,194
Solved Threads: 1,497
Skill Endorsements: 98

Oh. That worked well. Thanks for that. I should really read into the $_GET function. Seems almost magical.

reco21
Light Poster
43 posts since Jan 2011
Reputation Points: 14
Solved Threads: 1
Skill Endorsements: 0
Question Answered as of 2 Years Ago by pritaeas

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.1202 seconds using 2.71MB