1,105,625 Community Members

Tag archive page

Member Avatar
reco21
Light Poster
43 posts since Jan 2011
Reputation Points: 4 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
pritaeas
mod_pritaeas
11,318 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
1
 

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

Member Avatar
reco21
Light Poster
43 posts since Jan 2011
Reputation Points: 4 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
pritaeas
mod_pritaeas
11,318 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
1
 

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.
  }
}
Member Avatar
reco21
Light Poster
43 posts since Jan 2011
Reputation Points: 4 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Question Answered as of 3 Years Ago by pritaeas
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: