I am working on a site that needed three seperate modules showing the Most Recent, the Most Popular and Top Votes.
Here is the code for the Most Recent:
<?php // PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH', '../');
global $site_db, $cat_cache, $total_images;
// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
$num_images = 5;
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_date, a.image_active, a.image_thumb_file, a.image_comments
FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
WHERE a.image_active=1
AND a.cat_id = b.cat_id
AND a.cat_id != 23
AND b.auth_viewcat=".AUTH_ALL."
AND b.auth_viewimage=".AUTH_ALL."
ORDER BY a.image_date DESC
LIMIT $num_images";
$result = $site_db->query($sql);
if ($result) {
while ($row = $site_db->fetch_array($result)) {
$image_id = $row['image_id'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];
echo "<div style='float:left;width:66px;height:68px;margin:3px;padding-bottom:4px;'><div style='border:2px solid #ffffff;width:64px;height:64px;'><a href=\"".ROOT_PATH."details.php?image_id=$image_id\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\" width=\"64\" height=\"64\"></div>\n";
echo ShortenText($image_name)."\n";
echo "</div>\n";
}
}
?>
Here is the code for Most Popular:
<?php // PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH', '../');
global $site_db, $cat_cache, $total_images;
// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
$num_images = 12;
$sql = "SELECT a.image_id, a.cat_id, a.image_name, a.image_hits, a.image_active, a.image_thumb_file, a.image_comments
FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
WHERE a.image_active=1
AND a.cat_id = b.cat_id
AND a.cat_id != '23'
AND b.auth_viewcat=".AUTH_ALL."
AND b.auth_viewimage=".AUTH_ALL."
ORDER BY a.image_hits DESC
LIMIT $num_images";
$result = $site_db->query($sql);
if ($result) {
while ($row = $site_db->fetch_array($result)) {
$image_id = $row['image_id'];
$cat_id = $row['cat_id'];
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];
echo "<div style='float:left;width:66px;height:68px;margin:3px;'><div style='border:2px solid #f2f2f2;width:64px;height:64px;'><a href=\"".ROOT_PATH."details.php?image_id=$image_id\" title=\"$image_name\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\" width='64' height='64'><br>\n";
echo "</div></div>\n";
}
}
?>
Here is the code for the Top Votes:
<?php // PATH to your 4images Gallery / PFAD zu Ihrer 4images Gallerie
define('ROOT_PATH', '../');
global $site_db, $cat_cache, $total_images;
// NUMBER OF THUMBNAILS TO DISPLAY / NUMMER DER GEWÜNSCHTEN THUMBNAILS
$num_images = 8;
$sql = "SELECT DISTINCT a.image_id, a.cat_id, a.image_name, a.image_votes, a.image_active, a.image_thumb_file, a.image_comments, a.image_description, a.image_date
FROM ".IMAGES_TABLE." a, ".CATEGORIES_TABLE." b
WHERE a.image_active=1
AND a.cat_id = '23'
ORDER BY a.image_date DESC
LIMIT $num_images";
$result = $site_db->query($sql);
if ($result) {
while ($row = $site_db->fetch_array($result)) {
$image_id = $row['image_id'];
$cat_id = $row['cat_id'];
$image_description = $row['image_description'];
$image_name = $row['image_name'];
$image_comments = $row['image_comments'];
$thumb_src = (is_remote($row['image_thumb_file'])) ? $row['image_thumb_file'] : ROOT_PATH.THUMB_DIR."/".$cat_id."/".$row['image_thumb_file'];
echo "<div style='float:left;width:66px;height:68px;margin:3px;'><div style='border:2px solid #f2f2f2;width:64px;height:64px;'><a href=\"$image_description\" title=\"$image_name\" target=\"_blank\"><img src=\"".$thumb_src."\" border=\"0\" alt=\"$image_name\" width='64' height='64'><br>\n";
echo "</div></div>\n";
}
}
?>