Author Topic: Random image from only 1 category  (Read 2592 times)

0 Members and 1 Guest are viewing this topic.

Offline Lucifix

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
    • http://www.slo-foto.net
Random image from only 1 category
« on: February 26, 2006, 05:27:51 PM »
Can anyone help me with modify random image that would show images only from one category and they musn't be older then 7 days.

I tried to edit functions.php (AND i.cat_id = 24), but looks like this sql sentence isn't the right one:
Code: [Select]
    $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_points, i.image_hits, c.cat_name".get_user_table_field(", u.", "user_name")."
            FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c
            LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
            WHERE i.image_active = 1
            AND i.cat_id = 24
    AND i.cat_id NOT IN ($cat_id_sql)
    AND c.cat_id = i.cat_id
    AND i.image_date >= ".(time() - 60 * 60 * 168 * $config['new_cutoff'])."
            LIMIT $number, 1";