forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: Hot Rides on August 09, 2008, 03:39:18 pm

Title: what wrong with my code?
Post by: Hot Rides on August 09, 2008, 03:39:18 pm
why does this code not exclude albums with an id higher than 10000

Code: [Select]
$query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND aid > 9999 ORDER BY RAND() LIMIT $limit";

or am I way of base?
Title: Re: what wrong with my code?
Post by: Nibbler on August 09, 2008, 04:20:30 pm
Because you are requesting that the aid is larger than 9999. If you want only ones less than 10000 then use '< 10000'.
Title: Re: what wrong with my code?
Post by: Hot Rides on August 09, 2008, 05:34:38 pm
but its not limitng the search at all, its still showing all albums
Title: Re: what wrong with my code?
Post by: Nibbler on August 09, 2008, 05:53:10 pm
Post a link showing this.
Title: Re: what wrong with my code?
Post by: Hot Rides on August 09, 2008, 07:12:34 pm
www.hot-rides.net/forum
its the slider at the top, it pulls 30 random images from all albums, with user generated pics only making up about 1% of all files its hard to tell
Title: Re: what wrong with my code?
Post by: Hot Rides on August 09, 2008, 07:17:57 pm
i did some testing with lower numbers and it seems to be working now, I guess I have to just wait and see if it pulls from any user albums
Title: Re: what wrong with my code?
Post by: Nibbler on August 09, 2008, 07:22:04 pm
User albums are those with a category over 10000, you can't filter them out by looking at the aid.
Title: Re: what wrong with my code?
Post by: Hot Rides on August 09, 2008, 07:36:16 pm
all user created albums are 10000+, if I limit the string to 9999 or less it will effectivly filter out all user generated albums and the pictures inside them. My ultimate goal is only to filter private albums but I dont know the code well enough
Title: Re: what wrong with my code?
Post by: Hot Rides on August 09, 2008, 07:38:08 pm
edit, I see what you mean nibbler, im a fool, can I just use 'cat <9999' instead?
Title: Re: what wrong with my code?
Post by: Nibbler on August 09, 2008, 07:49:25 pm
No, since the category is a property of the album not the picture. To filter out user albums:

Code: [Select]
$query = "SELECT p.* FROM {$CONFIG['TABLE_PICTURES']} AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = p.aid WHERE approved = 'YES' AND category < 10000 ORDER BY RAND() LIMIT $limit";

To display only 'visible to everyone' albums:

Code: [Select]
$query = "SELECT p.* FROM {$CONFIG['TABLE_PICTURES']} AS p INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON a.aid = p.aid WHERE approved = 'YES' AND visibility = 0 ORDER BY RAND() LIMIT $limit";
Title: Re: what wrong with my code?
Post by: Hot Rides on August 09, 2008, 08:10:04 pm
thank you for the help Nibbler, Im sure these to lines of code will help me more in the future too.