Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Looking for some coding assitance

0 views
Skip to first unread message

Ted Appleberry

unread,
Mar 1, 2003, 2:16:04 AM3/1/03
to
Howdy all, first off, I couldn't code my way out of a wet paper bag
with a chainsaw, so be easy on me :-)
I am runing a BLOG, geeklog to be exact. It uses what are called
blocks, which are essentially plugins which are placed around the main
window and do all kinds of neat stuff.
Recently, I implemented a new graphics gallery called 4images, this is
great package! I asked the person who wrote the code to integrate
4images with Geeklog to see if he could write a block which showed a
listing of the last 5 - 10 new albums with new pictures added. He got
about 90% of it done but couldn't quite go the extra few miles. His
block as it currently stand will repeat the same album name over and
over if more then 1 image was added. What I want is each album only to
be listed once. Currently, If I add 13 pictures to album a and 4 to
album b, 3 to album c, it will show an entry for each new image, thus
it would shoiw album 13 as all five entries. Ideally it would show
album a, album b and album c because they all had photos added. Make
sense? If anybody could help me out I would appreciate it..
Thanks!
TA

Here is the code so far...

function phpblock_new4albums() {
global $_CONF, $_USER, $_TABLES;

$limit = "5";
$imgdir = "gallery";

$img_sql = DB_query("SELECT image_id FROM 4images_images");
$img_num = DB_numRows($img_sql);
$cat_sql = DB_query("SELECT cat_id FROM 4images_categories
WHERE (cat_parent_id!=0)");
$cat_num = DB_numRows($cat_sql);

$new .='<center>(' .$img_num. ' images in ' .$cat_num. '
albums)</center>';

// DATABASE
$new_sql = DB_query("SELECT DISTINCT cat_id,image_id FROM
4images_images ORDER BY image_id DESC LIMIT $limit");
while($N = DB_fetchArray($new_sql)){

$album =
DB_getItem("4images_categories",cat_name,"cat_id=$N[cat_id]");
$date =
DB_getItem("4images_images",image_date,"image_id=$N[image_id]");
$date = strftime('%b %d, %Y', $date);

$new .='<table width="98%"><td width="100%">';
$new .='<a href="' .$_CONF['site_url']. '/' .$imgdir.
'/categories.php?cat_id=' .$N['cat_id']. '">' .$album. '</a><br/>';
$new .='last updated: ' .$date;
$new .='</td></table>';

}

return $new;
}

cavebear

unread,
Mar 1, 2003, 1:36:28 PM3/1/03
to
On Fri, 28 Feb 2003 23:16:04 -0800, Ted Appleberry
<T...@appleberry.com> wrote:

>// DATABASE
> $new_sql = DB_query("SELECT DISTINCT cat_id,image_id FROM
>4images_images ORDER BY image_id DESC LIMIT $limit");


Change this SQL statement to:
$new_sql = DB_query("SELECT cat_id, MAX(image_id) as image_id FROM
4images_images GROUP BY cat_id ORDER BY image_id DESC LIMIT $limit");

That should do the trick.
--
YAWNS (Yet Another neverWinter Nights fan Site)
http://home.attbi.com/~cavebear/
Santa is Missing! Christmas adventure for NWN
http://nwvault.ign.com/Files/modules/data/1042522123185.shtml

Ted Appleberry

unread,
Mar 1, 2003, 1:44:56 PM3/1/03
to
You're a man god.. worked first time!

jp

0 new messages