PHP Classes

Comment: Manage a comment system using an SQL database

Recommend this page to a friend!
  Info   View files Example   View files View files (6)   DownloadInstall with Composer Download .zip   Reputation   Support forum (6)   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 57%Total: 3,044 All time: 1,201 This week: 177Up
Version License PHP version Categories
comment 1.0.0GNU Lesser Genera...4.0Databases, Content management
Description 

Author

This class can be used to manage a generic comments system. It could be used to add comments to a blog, a guest book, etc..

The comments are stored in an SQL database table. The class can install the table and associated indexes. Currently it supports MySQL and Microsoft SQL server.

The class can add new comments, update an existing comment, generate HTML forms to submit a comment and show the comments summary.

It works fine with PHP versions 4 and greater.

Innovation Award
PHP Programming Innovation award nominee
July 2006
Number 5


Prize: One downloadable copy of PhpED Professional
The possibility to post comments about the content that is published in Web site pages is very interesting.

It helps attracting more users that are able to participate in the site communities in a relevant way, even if it is just by letting them express their opinions.

This package provides a generic solution that could be used to let the users post comments about articles, blog posts, reviews, in guest books, etc..

Manuel Lemos
Picture of Peter Klauer
Name: Peter Klauer <contact>
Classes: 18 packages by
Country: Germany Germany
Age: 65
All time rank: 352 in Germany Germany
Week rank: 349 Down20 in Germany Germany Down
Innovation award
Innovation award
Nominee: 3x

Recommendations

What is the best PHP guestbook class?
I want to query a database and add names to a guestbook

Example

<html>
<head><title>Comment class example using mysql</title>

<?PHP

include '../includes/class_comment.php';
include
'../includes/class_sqltable.php';

#
# ... connect here to your sql server
#
$sqlconnection = mysql_connect('myserver','myusername','mypassword');
if (!
$sqlconnection) { die('Could not connect: ' . mysql_error()); }
mysql_select_db('mydatabase');

$sqltable = new sqltable( );
$sqltable->SQLTYPE = 'mysql';

$sqltable->install();

# $id_for and $code_for are the arguments.
# $sqltable is the table from above
# the empty string is the path to the css directory
# NOTE: $code_for is never allowed to have more than 8 characters.
#

$comment = new comment(0,'example',$sqltable, '../' );
$comment->SQLTYPE = 'mysql';

#
# MYSQL:
# install() will create the "comments" sql table under normal conditions and mysql.
#
# MSSQL:
# it will fail normally under mssql. Just copy the text from the mssql_query() of
# the install() function into your SQL Query Analyzer if the following install() fails.
# And then execute it with administrators rights. Don't forget to give
# the correct privileges to the freshly created table "comments"
#

$comment->install(); // Preparing, checking for sql table "comments", writing cssfile if not existing

?>

</head><body>

<h1>This is an example</h1>
This is some simple page which can be commented.
If the script is showing this text, then the comment class is properly installed.
<BR>
<BR>
<big>Congratulations!</big>

<BR>
<BR>
And here may come some comments, which may be re-edited by the author as long
as the internet connection does not change.

<BR>
<BR>

<div align=center><div style="text-align:left;width:80%;margin:0 auto">

<?php

#
# some optional options:
#

# $comment->debug = false; //true; // show additional info if true

# maybe we put some finedivs around the comment parts? (package ...)
# $comment->before_insert = $roundinput2->gettop(); // for example only, the finediv class is not initiated in this script
# $comment->after_insert = $roundinput2->getbottom();
# $comment->before_comments = $finediv->gettop();
# $comment->after_comments = $finediv->getbottom();

# $comment->showcomments = true; // Show the comments from start, don't wait on a mouseclick.

# $comment->prevent_multiple = false; // true by default

# $comment->prevent_spam = false; // allow links? Is true by default and changes input to $say_nolinks if a link is found

#
# to use in other languages, you may like to change
# all the "say_xxxx" text strings here like so for German text:
#

/*
  $comment->say_comment = 'Kommentar:<br><img src="images/writing2.gif" alt="Hand hält Feder">';
  $comment->say_comments = 'Kommentare';
  $comment->say_addcomment = 'Einen Kommentar hinzufügen';
  $comment->say_submit = 'Abschicken';
  $comment->say_nickname = 'Name/Alias:';
  $comment->say_update = 'Ändern';
  $comment->say_updated = 'Eintrag geändert.';
  $comment->say_close = 'Schließen (X)';
*/

$comment->put();

?>
</div></div>
</body></html>


  Files folder image Files  
File Role Description
Files folder imagecss (1 file)
Plain text file class_comment.php Class Show the comments
Accessible without login Plain text file class_comment_admin.php Aux. Use this class to validate the comments or to delete them
Accessible without login Plain text file test_comment.php Example How to implement the comment class
Accessible without login Plain text file License_LGPL-3.0.txt Lic. LGPL License
Accessible without login Plain text file CHANGELOG.txt Doc. Changes

  Files folder image Files  /  css  
File Role Description
  Accessible without login Plain text file comment.css Aux. Default CSS file

Downloadcomment-2011-05-02.zip 19KB
Downloadcomment-2011-05-02.tar.gz
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
SQL Table Download .zip .tar.gz Sqltable is needed to display the comment entries. Required
 Version Control Unique User Downloads Download Rankings  
 0%
Total:3,044
This week:0
All time:1,201
This week:177Up
User Ratings User Comments (2)
 All time
Utility:85%StarStarStarStarStar
Consistency:75%StarStarStarStar
Documentation:-
Examples:75%StarStarStarStar
Tests:-
Videos:-
Overall:57%StarStarStar
Rank:1534
 
well done
13 years ago (Naga Subrahmanyam)
52%StarStarStar
Excellent
14 years ago (kishore kumar)
70%StarStarStarStar