coppermine-gallery.com/forum

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: fangweile on December 27, 2011, 08:22:44 AM

Title: call list of albums in a category
Post by: fangweile on December 27, 2011, 08:22:44 AM
Hello there,

i am trying to create a custom page to display all albums in specific category in text link only.
for example

category 1                     category 2                        category 3
--> album 1 here            ---> album 1 here               ---> album 1 here 
--> album 2 here            ---> album 2 here               ---> album 2 here 
--> .....                        --->...                              ---> album ....

I used this code earlier and I manually listing all albums in a category. And it really take me a hard time doing it manually.
<?php
define
('IN_COPPERMINE'true);
require(
'include/init.inc.php');
pageheader('Album List (A-Z)');
starttable('Welcome');
?>

<div>
Album List Content here
</div>
<?php
endtable
();
pagefooter();
ob_end_flush();
?>


I have attached the screenshot how the list is being displayed..
Title: Re: call list of albums in a category
Post by: Αndré on January 04, 2012, 03:10:39 PM
Do you know your way around with SQL? It's done with some quite easy SELECT queries.
Title: Re: call list of albums in a category
Post by: fangweile on January 08, 2012, 02:03:13 PM
i am not that adept with sql and php coding and only knows some basic html coding. I am still learning about it and i think its getting me crazy lol   :o
Title: Re: call list of albums in a category
Post by: Αndré on January 10, 2012, 11:05:46 AM
Use a code like
$result = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = 13");
$rowset = cpg_db_fetch_rowset($result);
mysql_free_result($result);
foreach ($rowset as $album) {
    echo '<a href="thumbnails.php?album='.$album['aid'].'">'.$album['title'].'</a><br />';
}

for each category list.
Title: Re: call list of albums in a category
Post by: fangweile on January 10, 2012, 02:06:06 PM
Thanks a lot Αndré  ;), it works really great.
Title: Re: call list of albums in a category
Post by: Αndré on January 10, 2012, 02:55:18 PM
Then please:
Quote from: Joachim Müller on September 28, 2008, 12:46:26 PM
tag your answer as "solved" by clicking on the "Topic Solved" button on the bar at the left hand side at the bottom of your thread.