Results 1 to 1 of 1

Thread: Blog Entry Tagging/Keyword Script Troubles

  1. #1
    Join Date
    Mar 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Blog Entry Tagging/Keyword Script Troubles

    I am trying to code a PHP/MySQL script so I can add tags or keywords to entries on my existing blog.

    The general idea is this:

    Table1 (journal) contains the blog entries and their IDs (and some other data)
    Table2 (entry_tags) contains the IDs (from Table1) of each entry that has at least one tag and the IDs (from Table3) of the tags that go with each entry
    Table3 (tags) contains the actual tags and their IDs

    I have my script working so that I can add one tag per entry. I don't know how to change it so I can add multiple tags per entry.

    The input for this is a form INPUT field and the tags would be listed like this: art, friends, new zealand, vacation

    Here is my php code so far.

    PHP Code:
    if (isset ($_POST['submit']))
    {
        require_once (
    '../../mysql_connect.php');

        
    $query "INSERT INTO journal (entry_id, date, time, icon, mood, title, entry, perm_lvl) VALUE (0, '$date', '$time', '{$_POST['icon']}', '{$_POST['mood']}', '{$_POST['title']}', '{$_POST['entry']}', {$_POST['perm_lvl']})";
        
    $result = @mysql_query ($query);
        
    $entryid mysql_insert_id();

        if (isset (
    $_POST['tags']))
        {
            
    $query "INSERT INTO tags (tag_id, tag) VALUE (0, '{$_POST['tags']}')";
            
    $result = @mysql_query ($query);
        } else
        {
            print 
    '<center>Please indicate at least one tag for this entry.</center><br />';
        }

        
    $query "INSERT INTO entry_tags (id, entry_id, tag_id) VALUE (0, '$entryid', LAST_INSERT_ID())";

        if (@
    mysql_query ($query))
        {
            print 
    '<center>The entry has been added.</center><br />';
        } else
        {
            print 
    "<center>Could not add the entry because: <b>" mysql_error() . "</b>.<br /><br />
            The query was 
    $query.<br /><br />";
        }

        
    mysql_close(); 
    Any help appreciated, thanks!
    Last edited by Shai; 04-28-2008 at 11:15 PM. Reason: Figured out one of the issues I was having. Edited to concentrate on the remainder!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •