ahoj nevim co s tim mam objektovou komponentu na vypsani obsahu z db ale nejak mi to nechce vypisovat muzete mi rict zada je nekde neco spatne data se odeslou v poradku ale zpetny vytah nefunguje zde je kod
jde predevsim o funkci writeAllContent
<?php
/**
* Description of WriteContent
*
* @author Martin „ichis“ Suchodol <tribal.cz@gmail.com>
*/
class WriteContent {
public function selectContentNews()
{
$result = Database::query('SELECT * FROM `news` WHERE `date` ORDER BY `date` DESC LIMIT 5');
return $result;
}
private function saveContentNews($title, $text, $created,$archived)
{
Database::query('INSERT INTO `news` (`date`,`nick`,`title`,`text`,`created`,`archived`) VALUES (NOW(),?,?,?,?,?)', array($_SESSION['login'], $title, $text, $created ,$archived));
}
public function countRecords($class)
{
$result = $class;
$result->rowCount();
}
public function writeAllContent($class)
{
$result = $class;
$result->fetchAll();
foreach($result as $res)
{
echo("<div>");
echo("<span class=\"title\">" . $res['title'] . "</span>");
echo("</div>");
echo("<div>");
echo("<span class=\"date\">" . $res['date'] . "</span>");
echo("</div>");
echo("<div>");
echo("<p class=\"content\">" . $res['text'] . "</p>");
echo("</div>");
}
}
public function createNewsForm()
{
$form = new Form();
echo("<form method=\"post\">");
echo("<div>");
echo("<label for=\"title\">Nick:<span class=\"small\">Vyplňte svůj nick</span></label>");
echo(" " . $form->input('text', 'title', 'title', '', 1));
echo("</div>");
echo("<div>");
echo("<label for=\"text\">Text:<span class=\"small\">Vyplňte text novinky</span></label>");
echo("" . $form->textarea('text', 'text', '', 5, 15, 2));
echo("</div>");
echo("<div>");
echo(" " . $form->button('submit', 'goNews', 'Odeslat'));
echo("</div>");
echo("</form>");
}
public function createNews()
{
if(isset($_POST['goNews']))
{
$result = $this->saveContentNews($_POST['title'], $_POST['text'], time(), 0);
}
}
}
?>
edit funkci a classu vypisuji takto
<?php
$w = new WriteContent();
$w->createNewsForm();
$w->createNews();
$w->writeAllContent($w->selectContentNews());
?>