forum.coppermine-gallery.net

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Miscellaneous => Topic started by: LordNeon on July 04, 2005, 04:38:27 pm

Title: SQL Query?
Post by: LordNeon on July 04, 2005, 04:38:27 pm
Hello.

I'm writing a function in the theme.php file of my own template.
The goal of this function is to display all albums as links on the left side of my webpage.
I've managed to do that, but a small problem is still there;
I'm only getting one result of the query and there's 26 entries in my database.
For some reason it won't display the whole loop in my function.

Here's my function as for now:
Code: [Select]
function get_album_list() {
global $CONFIG, $template_custom_album_list;

static $template = '';
static $album_list;
if ((!$template)) {
$template = $template_custom_album_list;
//$album_list = template_extract_block($template, 'custom_album_list');
}

$sql = "SELECT title, aid FROM {$CONFIG['TABLE_ALBUMS']} ORDER BY title ASC";
$result = db_query($sql) OR die(mysql_error());
$rowset = db_fetch_rowset($result);
mysql_free_result($result);
foreach($rowset AS $key => $row)
{
$album_name[$key] = $rowset[$key]['title'];
$album_id[$key] = $rowset[$key]['aid'];
$param[$key] = Array('{CUSTOM_ALBUM_NAME}' => $album_name[$key], '{CUSTOM_ALBUM_ID}' => $album_id[$key]);
$custom_album_list = template_eval($template, $param[$key]);
}
return $custom_album_list;
}

Thank you in advance.