I feel like a newbie... 10 years since my last post on usenet and still
fresh as ever. So to the point.
del.icio.us, flickr, technorati all have tag based systems. Therefore
I must have one as well. Stuck would be the place where I am now.
Below is the code that I have already and the table layout. I just
need a push in the right direction. I am using this as not only a
learn to do it project but who knows what the boss will think. Thanks
for any help.
The tables...
Three tables
bookmarks
tags_bookmarks
tags
tags_bookmarks is a two field linking table for the many to many
relationship between bookmarks and tags (primary id is combination of
the two liniking fields tagID and bookmarkID)
I have figured out how to add the data and link the records the trouble
is with getting the tags and the data out. Here's what I have so far.
function outputTags($tag) {
if (!$tag) {
$tag_array = $this->getRecords("SELECT tag FROM tags"); // A
simple place holding query
} else {
$tag_array = $this->getRecords("SELECT tag FROM tags"); // A simple
place holding query
}
$output = "<ul>";
foreach ($tag_array as $tag) {
$tag_name = $tag['tags'];
$output .= "<li><a href=\"view_marks.php?link_tag=" . $tag_name .
"\">" . $tag_name . "</a></li>";
}
$output .= "</ul>";
return $output;
}
function getBookmarks($tag) {
$bookmarks = $this->getRecords("SELECT bookmarks.* FROM bookmarks,
tags, tags_bookmarks WHERE bookmarks.bookmarkID =
tags_bookmarks.bookmarkID AND tags_bookmarks.tagID = tags.tagID AND
tags.tag = '$tag'");
$output = "<ul>";
foreach ($bookmarks as $b) {
$title = $b['title'];
$url = $b['url'];
$output .= "<li>" . $title . "</li>";
}
$output .= "</ul>";
return $output;
}
It is the trouble I think ( and I could be so wrong it's not funny)
with the SQL statements and getting the right data. What I want it to
do is when I first click/select a tag is looks up all the related tags
and shows just the related tags. Therefore, when I click the tag
"Software" I want to see all the bookmarks and Tags that are associated
with "Software", however I also want to be able to dig down into the
tags. I want to be able to go down into the tags list, but not like
del.icio.us, that just keeps showing all the tags again. What I want
to happen is if I click "Software" and then click "OS X" I only want to
see tags associated with "Software" AND "OS X".... and of course the
bookmarks that go with it. I hope that explains the issues that I am
having. Any ideas or pointers? Again thanks for any help.
A.<!-- ~MESSAGE_AFTER~ -->