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.

Recommended Answers

All 4 Replies

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

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.

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.
  }
}
commented: Thanks very much. +0

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.