[eluser]ShoeLace1291[/eluser]
I realize that there is a section in the user guide about this, but I'm trying to parse database results but with a little more to it.
This is my controller:
Code:
$query = $this->db->query("
SELECT *
FROM albums
WHERE author_id = ".$member['id']."
ORDER BY id DESC LIMIT 5");
$albums = array();
foreach($query->result_array() as $album){
$author = $this->member->context($album['author_id']);
$query2 = $this->db->query("
SELECT *
FROM photos
WHERE album_id = ".$album['id']."
ORDER BY RAND()
LIMIT 1");
$cover = $query2->row_array();
$member_album = array(
'ALBUM_ID' => $album['id'],
'ALBUM_TITLE' => $album['title'],
'ALBUM_DESCRIPTION' => nl2br(htmlspecialchars($album['description'])),
'ALBUM_LINK' => anchor('gallery/albums/'.url_title($album['title']).'/'.$album['id'], $album['title']),
'ALBUM_COVER' => anchor('gallery/photos/'.url_title($cover['title']).'/'.$cover['id'], "<img src='".base_url()."/attachments/".$cover[' width='295' height='150' title='".$album['>"),
'ALBUM_POST_DATE' => date('M jS, Y', $album['date_posted'])
);
$albums = array_merge($albums, $member_album);
}
$data = array(
'MEMBER_ALBUMS' => $albums
);
$this->parser->parse('gallery/gallery_index.tpl', $data);
All the code does is display the variables as is. When I print the array, it displays just like the user guide example arrays do.