Support > cpg1.5 miscellaneous
API to fetch last updated albums
(1/1)
Sweetener:
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: ---<?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 '\');';
?>
--- End code ---
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é:
This is the code Coppermine uses for the "last updated albums" meta album:
--- Code: (include/functions.inc.php) --- $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";
--- End code ---
Sweetener:
Which $RESTRICTEDWHERE uses the last updated albums in index.php?
ron4mac:
--- Quote from: Sweetener on August 30, 2019, 12:57:42 am ---Which $RESTRICTEDWHERE uses the last updated albums in index.php?
--- End quote ---
"WHERE (1)"
So really ... just don't use it.
Navigation
[0] Message Index
Go to full version