简单的ajax评论完整代码
数据库结构CREATE TABLE `comments` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(128) collate utf8_unicode_ci NOT NULL default '',
`url` varchar(255) collate utf8_unicode_ci NOT NULL default '',
`email` varchar(255) collate utf8_unicode_ci NOT NULL default '',
`body` text collate utf8_unicode_ci NOT NULL,
`dt` timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
- <?PHP
- //Errorreporting:
- error_reporting(E_ALL^E_NOTICE);
- include"conn.PHP";
- include"comment.class.PHP";
- /*
- /Selectallthecommentsandpopulatethe$commentsarraywithobjects
- */
- $comments=array();
- $result=MysqL_query("SELECT*FROMcommentsORDERBYidASC");
- while($row=MysqL_fetch_assoc($result))
- {
- $comments[]=newComment($row);
- }
- ?>