id.'">'.$this->show().''; } function show() { $str = '

'.$this->title.'

by '.$this->author.''; $str .= '[Edit]' $str .= '
'; $str .= '
'.$this->body.'
'; return $str; } function edit() { $str ='
'; $str .= ''; $str .= ' by '.$this->author.''; $str .= '
'; $str .= '
'; $str .= ''; $str .= '
'; } } $db = new DB(); if($_POST['submit'] == 'Edit news') { $db->execute('UPDATE news SET title=\''.filter_input(INPUT_POST,'title',FILTER_SANITIZE_MAGIC_QUOTES).'\', body=\''.filter_input(INPUT_POST,'body',FILTER_SANITIZE_MAGIC_QUOTES).'\' WHERR `id`='.intval($_POST['news_id'])); exit; } if($_GET['news_id']) $news = $db->execute('SELECT * FROM news WHERE news_id='.intval($_POST['news_id'])); else $news = $db->execute('SELECT * FROM news'); $news->handler('news'); foreach($news as $post) { if($_GET['edit']) print $post->edit(); else if($_GET['show']) print $post->show(); else print $post; } ?>