Feed back script

Discussion in 'PHP' started by Jim bob 9 pants, May 30, 2006.

  1. #1
    Hi

    I want people to be able to add comments to articles and reviews I am writing, like a blog.

    I have looked through hotscripts but no luck yet - I could start to write a script myself I guess but it will take me a while (not very php savvy)

    Any ideas??

    Jamie

    PS it must be free
     
    Jim bob 9 pants, May 30, 2006 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Would depend on how your articles are organised.

    Pretty simple to code since it's basic forms + basic database stuff.

    Say your articles are in a table and each has a unique ID.

    Create another table with:
    commentID (INT 11 - Autoincrement)
    articleID (INT11 - same as in your article table)
    user(VARCHAR 64 - for the name of the submitter)
    comment(TEXT)

    You could add IP, email etc. to avoid spam and what not, maybe a timestamp etc.

    Then under your article, SELECT * FROM article_comments WHERE articleID = $current_id;
    while($comment = mysql_fetch_array($sql)){
    echo $comment['user'] . ' said: ' . $comment['comment'];
    }

    Then a form with name and comment which is stored in the DB.

    That's it, almost done :)
     
    T0PS3O, May 30, 2006 IP
  3. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Cool TOPS - The articles are just static pages so the bit that confused me is how to link the comments in the db to the static page
     
    Jim bob 9 pants, May 30, 2006 IP
  4. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #4
    That's a shame because that will make it very hard. You could use the URL as the unique ID but then still you have to put PHP in html files.

    Sounds like you have outgrown 'static' and need a proper CMS.
     
    T0PS3O, Jun 1, 2006 IP
  5. clancey

    clancey Peon

    Messages:
    1,099
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Another approach with "static" pages is to separate the header, footer and content sections. This allows you to request all pages through a single php program, which sends out a header, the articles and a footer.

    Under my implementation all news articles are numbered. That number could be used to find a record in a database which includes comments. Therefore, when the php script gets a request for a page it can extract the article number to find the article file and also use the article number to retrieve comments from a database.

    When comments are made on an article, the program just needs to remember the article number and insert that into an appropriate spot in the database record.

    I do not want to debate the point, but do not get overwhelmed by concept of a CMS get to you. Your system is already a rudimentary CMS. Therefore, all you are really looking at here is a way to extend the functionality of your CMS to include comments. You may decide you need to reimplement the whole thing; or you may find it easier to extend what you already have.
     
    clancey, Jun 1, 2006 IP
  6. Jim bob 9 pants

    Jim bob 9 pants Peon

    Messages:
    890
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thank you both for your comments, I think I will expand the site with my own long winded scripting!!

    I want to make an area for attractions for the area as well - so I may as well expand what I have got as I know how it works and make an attraction and article data base and then intergrate it all together. I just wish that google maps used a poscode data base so I didnt have to find lat and longs for the UK, it would make everything sooooooo much easier as I cannot currently justify buying a post code data base.

    Also this site is kinda may baby, not a fast growing one like most babies, but it does keep me up all night LOL. I would be happier to use this platform rather than using an off the shelf CMS. It gives me a feeling of pride that my friends hard work initially coding it then my changes and re working it are my doing and its sucess and the money it earns are through MY work. A bit sentimental I guess.

    Jamie
     
    Jim bob 9 pants, Jun 2, 2006 IP