Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: API to fetch last updated albums  (Read 19777 times)

0 Members and 2 Guests are viewing this topic.

Sweetener

  • Contributor
  • Coppermine regular visitor
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 64
API to fetch last updated albums
« on: July 07, 2018, 11:09:39 pm »

Hello there! I've been trying to do my own api to get some of the last updated albums like coppermine in their index do:
https://i.imgur.com/S9H5ywT.png

Sadly I just have the last created albums
https://i.imgur.com/5jxnZts.png

Code: [Select]
<?php
require_once(
'include/config.inc.php');
header("Content-type: application/x-javascript");

$connect mysql_connect('localhost','dbuser','dbpass') or die('Error conexion server');
$connect_db mysql_select_db('dbname'$connect) or die ('Error conexion base de datos');

$resultado mysql_query("SELECT * FROM cpgq7_albums ORDER BY aid DESC LIMIT 0 ,6"$connect) or die('Ningun album encontrado'); echo 'document.write(\'';

if(mysql_num_rows($resultado) == 0){
echo 'Ningun album obtenido';
} else {

echo 
'<div class="photos">  ';
while($row mysql_fetch_array($resultado)){
echo ' ';
$album_id $row['aid'];
$subresult mysql_query("SELECT * FROM cpgq7_pictures where aid=$album_id order by pid DESC LIMIT 0, 6");

if(mysql_num_rows($subresult) == 0){
$album_img "http://arianagrandechile.net/galeria/thumbs/thumb_nopic.png";
} else {
while($subrow mysql_fetch_array($subresult)){
$album_img "http://arianagrandechile.net/galeria/albums/".$subrow['filepath'].'normal_'.$subrow['filename']  .$subrow['datebrowse'];
}
}
echo '<div class="g-album">';
echo '<a href="http://arianagrandechile.net/galeria/thumbnails.php?album='.$album_id.' " target="_blank"><img src="'.$album_img.'" alt="" /></a>';
echo '<div class="g-title"><a href="http://arianagrandechile.net/galeria/thumbnails.php?album='.$album_id.' " target="_blank">'.$row['title'].'</a></div>';
echo "</div>";
}
echo '</div>';
}
echo '\');';
?>


I know there is something wrong with my code because I'm fetching the last aid, but how do I do something like cpgp do?

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: API to fetch last updated albums
« Reply #1 on: August 15, 2018, 01:48:21 pm »

This is the code Coppermine uses for the "last updated albums" meta album:
Code: (include/functions.inc.php) [Select]
        $query = "SELECT $select_columns_albums
                FROM {$CONFIG['TABLE_PICTURES']} AS r
                INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = r.aid
                $RESTRICTEDWHERE
                AND approved = 'YES'
                GROUP BY r.aid
                ORDER BY ctime DESC
                $limit";
Logged

Sweetener

  • Contributor
  • Coppermine regular visitor
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 64
Re: API to fetch last updated albums
« Reply #2 on: August 30, 2019, 12:57:42 am »

Which $RESTRICTEDWHERE uses the last updated albums in index.php?

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: API to fetch last updated albums
« Reply #3 on: August 30, 2019, 01:20:09 pm »

Which $RESTRICTEDWHERE uses the last updated albums in index.php?

"WHERE (1)"

So really ... just don't use it.
Logged
Pages: [1]   Go Up
 

Page created in 0.021 seconds with 19 queries.