I am trying to print out a feed of posts into a html template that gets pushed into the page and cached. However i seem to only know how to print out one record into the html file instead of being able to built it up.
Best way i can explain it is i want posts to be some kind of array that keeps adding the $posts->display() of every record in the table to the end of the last one so posts would end up like.
where just now the output is
Best way i can explain it is i want posts to be some kind of array that keeps adding the $posts->display() of every record in the table to the end of the last one so posts would end up like.
HTML:
<h2>Title</h2>
<p>Body text bla bla bal</p>
<h2>Tittle2</h2>
<p>body 2</p>
<!-- etc. -->
where just now the output is
HTML:
<h2>Tittle2</h2>
<p>body 2</p>
PHP:
/* Connect to the table */
$task = "dbmysql";
$query_select = "select `id`, `body`, `title`, `author`, `date` from `homePage`";
$database_name = "abcomfor_groupproject";
/* Initialise the database */
$dbC = new DbControl($task);
$dbC->selectDb($database_name);
$dbC->setQuery($query_select);
$dbR = $dbC->initiate();
// Cycles though the results to see if the user exists //
while ($dbR->next())
{
/* Feed the post into the template */
$postFeed=array
(
'title'=>$dbR->get("title"),
'body'=>$dbR->get("body"),
'author'=>$dbR->get("author"),
'date'=>$dbR->get("date"),
'body'=>$dbR->get("body")
);
$posts =&new templateParserNoCache('../application/modules/bootstrap/views/posts.tpl.htm');
$posts->parseTemplate($postFeed);
// Echos the product //
$posts = $posts->display();
}
echo $posts;