Advanced search  

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

Pages: [1]   Go Down

Author Topic: what wrong with my code?  (Read 2949 times)

0 Members and 1 Guest are viewing this topic.

Hot Rides

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 108
  • I am
    • Hot Rides Show & Cruise
what wrong with my code?
« 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?
Logged

Nibbler

  • Guest
Re: what wrong with my code?
« Reply #1 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'.
Logged

Hot Rides

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 108
  • I am
    • Hot Rides Show & Cruise
Re: what wrong with my code?
« Reply #2 on: August 09, 2008, 05:34:38 pm »

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

Nibbler

  • Guest
Re: what wrong with my code?
« Reply #3 on: August 09, 2008, 05:53:10 pm »

Post a link showing this.
Logged

Hot Rides

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 108
  • I am
    • Hot Rides Show & Cruise
Re: what wrong with my code?
« Reply #4 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
Logged

Hot Rides

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 108
  • I am
    • Hot Rides Show & Cruise
Re: what wrong with my code?
« Reply #5 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
Logged

Nibbler

  • Guest
Re: what wrong with my code?
« Reply #6 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.
Logged

Hot Rides

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 108
  • I am
    • Hot Rides Show & Cruise
Re: what wrong with my code?
« Reply #7 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
Logged

Hot Rides

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 108
  • I am
    • Hot Rides Show & Cruise
Re: what wrong with my code?
« Reply #8 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?
Logged

Nibbler

  • Guest
Re: what wrong with my code?
« Reply #9 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";
Logged

Hot Rides

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 108
  • I am
    • Hot Rides Show & Cruise
Re: what wrong with my code?
« Reply #10 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.
Logged
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 20 queries.