Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Tags and Keywords

 
   Database Help (Home) -> PHP RSS
Next:  Regex and external functions  
Author Message
Andrew

External


Since: Feb 12, 2005
Posts: 2



(Msg. 1) Posted: Sat Feb 12, 2005 2:23 pm
Post subject: Tags and Keywords
Archived from groups: alt>php (more info?)

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~ -->

 >> Stay informed about: Tags and Keywords 
Back to top
Login to vote
oli_filth

External


Since: Dec 02, 2004
Posts: 40



(Msg. 2) Posted: Sun Feb 13, 2005 11:40 am
Post subject: Re: Tags and Keywords [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Andrew wrote:
 > 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)
 >
<SNIP>
 > 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.

How are you storing the relationships between tags? i.e. how does your
database know that the "OS X" tag is associated with the "Software" tag?

--
Oli<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: Tags and Keywords 
Back to top
Login to vote
Andrew

External


Since: Feb 12, 2005
Posts: 2



(Msg. 3) Posted: Sun Feb 13, 2005 12:33 pm
Post subject: Re: Tags and Keywords [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 2005-02-13 10:37:29 -0500, Oli Filth <oli_filth.RemoveThis@eatspam.coldmail.com> said:

They don't really, except by the bookmarks. The tables are set up as a
many to many between bookmarks and tags. So the "tags_bookmarks" is a
two field table that holds the associated id's between bookmarks and
tags (a cross-reference table). Therefore, if I have a bookmarks
pointing to <a style='text-decoration: underline;' href="http://www.versiontracker.com" target="_blank">www.versiontracker.com</a> the tags associated to that url
would be "OS X" and "Software" and whatever else I want. What I think
the solution should be is to take the "Software" tag ID and look for it
associated with other bookmarks and pull out all the tags that are also
associated with those bookmarks. Then when I click on "OS X" next it
looks for the bookmarks that have both "Software" and "OS X" associated
with them. But I am unsure how this would be done.

From what I am learning - it could be a recursive function where it
just keeps going until all the bookmarks have been gone through, then
again perhaps not. The whole setup may be wrong, but I want to keep
all the data separate (normalized) because I might use the tags table
with other tables (say a todo table, or a journal table) so I can tag
all the data in my system and do a search.

If anyone can think of a better way I would go down that route. Hope
this explains things a bit better, then again maybe not. Thanks.



 > Andrew wrote:
  >> 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)
  >>
 > <SNIP>
  >> 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.
 >
 > How are you storing the relationships between tags? i.e. how does your
 > database know that the "OS X" tag is associated with the "Software" tag?<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Tags and Keywords 
Back to top
Login to vote
Display posts from previous:   
   Database Help (Home) -> PHP All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]