what wrong with my code? what wrong with my code?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

what wrong with my code?

Started by Hot Rides, August 09, 2008, 03:39:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Hot Rides

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?

Nibbler

Because you are requesting that the aid is larger than 9999. If you want only ones less than 10000 then use '< 10000'.

Hot Rides

but its not limitng the search at all, its still showing all albums

Nibbler


Hot Rides

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

Hot Rides

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

Nibbler

User albums are those with a category over 10000, you can't filter them out by looking at the aid.

Hot Rides

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

Hot Rides

edit, I see what you mean nibbler, im a fool, can I just use 'cat <9999' instead?

Nibbler

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";


Hot Rides

thank you for the help Nibbler, Im sure these to lines of code will help me more in the future too.