I like the posted MOD, but there were a few errors on the previous post. I am not a PHP coder, but I seemed to have it working now after some fixes. Although I am having problems in the sort order. I would like the parent category in alpha order. Can anyone help?
<?php
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$number_of_new_pics = 25;
$days_to_be_new = 30;
$new_cutoff = time() - 60 * 60 * 24 * $days_to_be_new;
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$sql = "SELECT MAX(cat_id) as max_id FROM ".CATEGORIES_TABLE;
$row = $site_db->query_firstrow($sql);
$cat_max_id = (!empty($row['max_id'])) ? $row['max_id'] : 0;
for ($i = 0; $i <= $cat_max_id; $i++){
$sql = "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name, c.cat_id
FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c
WHERE i.image_active = 1 AND i.image_date >= $new_cutoff AND c.cat_id = i.cat_id AND i.cat_id = $i
ORDER BY c.cat_id";
$result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
$images_in_category = $site_db->get_numrows($result);
$category_name = ($row['cat_name']);
$category_id = ($row['cat_id']);
$category_link = ("<a href=\"" . ROOT_PATH . "categories.php?cat_id=" . $category_id . "\">");
if ($images_in_category) { echo "<br /><table border=\"0\"><tr><td class=\"row1\" width=\"300\" height=\"30\">Category: $category_link<b>$category_name</b></a> <b>$images_in_category</b> new file(s):</td></tr>"; }
$sql = "SELECT i.image_id, i.cat_id, i.image_active, i.image_name, i.image_date, c.cat_name, u.user_name
FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c
LEFT JOIN ".USERS_TABLE." u ON u.user_id = i.user_id
WHERE i.image_active = 1 AND i.image_date >= $new_cutoff AND c.cat_id = i.cat_id AND i.cat_id = $i
ORDER BY ".$config['image_order']." ".$config['image_sort']."
LIMIT $number_of_new_pics";
$result = $site_db->query($sql);
while ($row = $site_db->fetch_array($result)) {
$image_name = ($row['image_name']);
$image_id = ($row['image_id']);
$category_name = ($row['cat_name']);
$user_name = ($row['user_name']);
$media_path = ($row['image_media_file']);
$image_date = format_date($config['date_format']." ".$config['time_format'],$row['image_date']);
$image_link = ("<a href=\"" . ROOT_PATH . "details.php?image_id=" . $image_id . "\">");
$allnew_link = ("<a href=\"" . ROOT_PATH . "search.php?search_new_images=1" . "\">");
echo "<tr><td class=\"row2\" height=\"30\">$image_link<b>$image_name</b></a></td></tr>";
// - $image_date<br />";
}
}
if ($image_name == "") {
echo "There have been no new files added in the last 30 days<br />";
}
echo "<tr><td class=\"row1\" align=\"right\"><a href=\"search.php?search_new_images=1\">All new images</a></td></tr></table>
";
?>