SQL Query? SQL Query?
 

News:

CPG Release 1.6.27
change DB IP storage fields to accommodate IPv6 addresses
remove use of E_STRICT (PHP 8.4 deprecated)
update README to reflect new website
align code with new .com CPG website
correct deprecation in captcha

Main Menu

SQL Query?

Started by LordNeon, July 04, 2005, 04:38:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LordNeon

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:

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.