Napisałem sobie klasę obsługującą dodawanie komentarzy do bazy danych:
<?php class Comments { public $autor; public $content; public function __construct() { $this->autor = $this->filter($_POST['autor']);; $this->content = $this->filter($_POST['content']); } public function addComment() { return mysql_query("INSERT INTO comments(autor, content) VALUES ('{$this->autor}','{$this->content}')"); } public function editComment(){ } public function filter($var) { } }
<table> <tr><td>Autor:</td><td><input type="text" name="autor"/></td></tr> <tr><td>Content:</td><td><input type="text" name="content"/></td></tr> </table> <input type="submit" name="dodaj" value="Dodaj"/> </form> <?php include_once('/class.comments.php'); $comments = new Comments; $comments->addComment(); ?>
Jak zabrać się za metodę która będzie edytowała wybrany komentarz?