Results 1 to 3 of 3
  1. #1

    Need php comment script

    Hi,

    I am looking for a comment script for a tutorial website. What I need is fairly simple:

    I need to be able to create different comment pages so that each tutorial page can have its own comments. Automation is great if possible.

    I need to have a sum of all the comments so that I can place something on my site where it could say "Total comments: xxx"

    Anyone know of a script I could use? I found one comment script, from scriptsmill or whatever, but it can only be used for a single page (without duplicating the script dozens of times). I need one for multiple pages.

    Thanks,

    Taylor

  2. #2
    It is fairly simple i'd say. To make this script you have to ask yourself, what is really a comment script ? Just basicaly few texts stored in one database and have the same article id.

    MySQL structure could be something like this:

    CommentID (index, int, auto_increment)
    Author (varchar [20])
    Comment (text)

    Then the php code would be fairly simple. To fetch the number of comments:

    PHP Code:
    $conn mysql_connect($user$password$host);
    if(
    $conn)
    {
    die (
    'MySQL is dead');
    }
    else
    {
    mysql_select_db($dbname);

    # $articleid can be virtualy anything, or just the $_GET['articleid'] or anything else
    $q mysql_query("SELECT count(*) AS Total FROM comment_table WHERE ArticleID = $articleid");

    if (!
    $q)
    {
    echo 
    'MySQL error';
    }
    else
    {
    $res mysql_fetch_object($res);

    echo 
    $res->Total ' Comments';
    }

    To display them just do something like


    PHP Code:
    $conn mysql_connect($user$password$host);
    if(
    $conn)
    {
    die (
    'MySQL is dead');
    }
    else
    {
    mysql_select_db($dbname);

    # $articleid can be virtualy anything, or just the $_GET['articleid'] or anything else
    $q mysql_query("SELECT * FROM comment_table WHERE ArticleID = $articleid");

    if (!
    $q)
    {
    echo 
    'MySQL error';
    }
    else
    {
    while (
    $data mysql_fetch_array($q))
    {
    echo 
    '<strong>' $data['Author'] . '</strong>';
    echo 
    'Comment: ' $data['Comment'];
    }
    }


  3. #3
    Join Date
    Aug 2002
    Posts
    512
    I would do it the same way as Renard does. If you don't feel like creating a script yourself you can always install wordpress or something like that. It's really easy to customize or build your own template, has superb support, plugins, etc and its free with all kind of comment and filter functions.

Posting Permissions

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