PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
$description = 'My Blog';
require 'header.php';
//get the 10 latest blogs
$blogr = mysql_query("SELECT * FROM `blogs` ORDER BY `id` DESC LIMIT 10") or die(mysql_error());
while($blog_a = mysql_fetch_assoc($blogr))
{
$tpl->assign('blog_title', $blog_a['title']);
$tpl->assign('blog_music', $blog_a['music']);
$tpl->assign('blog_mood', $blog_a['mood']);
$tpl->assign('blog_time', date("n-d-Y \a\\t g:i A", $blog_a['time']));
$tpl->assign('blog_entry', $blog_a['entry']);
}
$tpl->display('blog.tpl');
require 'footer.php';
?>
I'm having trouble figuring out how to assign the variables from the $blog_a array into the template (template lite). By doing it like I am above, it will only list one blog on the page. I want to show 10.
The only thing I can think of would be assigning $blog_a to a container array inside of the loop and pass that container array to the template, and then loop over it in the template. That seems a bit... far fetched. Am I missing something extremely obvious?
Seems a bit odd at first, but I suppose anything out of the ordinary from what I've been doing will seem odd. Hopefully this is the most practical way of doing it. Seems like it'd use more resources by assigning to an extra array, though.