db = $db; } public function load_comments(){ $comments = array(); $comms = $this->db->sql_select('comments'); if (mysql_num_rows($comms) > 0){ while($com = mysql_fetch_assoc($comms)){ $comments[] = $com; } } $this->comments = $comments; } public function add_comment($name, $text){ $this->db->raw_query('INSERT INTO comments (name, time, text) VALUES (\''.$name.'\', '.time().', \''.$text.'\')'); } public function display_comment_form(){ if (isset($_POST['submit']) && $_POST['submit'] == 'Add Comment'){ $messages = array(); if (empty($_POST['name'])) $messages[] = 'You need to enter a name'; if (empty($_POST['comment']) || $_POST['comment'] == 'Comment') $messages[] = 'You need to enter a comment'; if (empty($messages)){ self::add_comment($_POST['name'], $_POST['comment']); } else { print(''); } } ?>
Name:

comments)) self::load_comments(); if (!empty($this->comments)){ foreach($this->comments as $comment){ print('
By: '.$comment['name'].' on '.date('m-d-Y', $comment['time']).'
Comment:
'.$comment['text'].'
'); } } else { print('there are no comments yet.'); } } } ?> Untitled Document display_comment_form(); $comment->display_comments(); $db->print_log(); ?>