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
-
why does this code not exclude albums with an id higher than 10000
$query = "SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND aid > 9999 ORDER BY RAND() LIMIT $limit";
or am I way of base?
-
Because you are requesting that the aid is larger than 9999. If you want only ones less than 10000 then use '< 10000'.
-
but its not limitng the search at all, its still showing all albums
-
Post a link showing this.
-
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
-
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
-
User albums are those with a category over 10000, you can't filter them out by looking at the aid.
-
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
-
edit, I see what you mean nibbler, im a fool, can I just use 'cat <9999' instead?
-
No, since the category is a property of the album not the picture. To filter out user albums:
$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:
$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";
-
thank you for the help Nibbler, Im sure these to lines of code will help me more in the future too.