1
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
$cat_in = array(2,7,8,11,12,15,16,18); //list of category ids // *** TO FILTER RANDOM IMAGES ***
$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_hits".$additional_sql.", 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 c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").") AND i.cat_id IN (".implode(", ", $cat_in).")
ORDER BY RAND()
LIMIT $num_new_images";
whatever is works for you. for some people is easier remove few categories from the list for others is easier to use only few specific categories...right
anyway, as Хyu BAM said in her(?) last reply, the only line should be changed is in this block:it's not working, same situation. e.g.: i have 10 categories and with this example it works for the categories 1-3, but the most time (7/10) there is no random-image (empty).
$number = ($total_images > 1) ? mt_rand(0, $total_images - 1) : 0;
$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_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 NOT IN ($cat_id_sql) AND c.cat_id = i.cat_id AND i.cat_id IN (".implode(", ", $cat_in).")
LIMIT $number, 1";
$random_image_cache[0] = $site_db->query_firstrow($sql);
mt_srand((double)microtime() * 1000000);
$sql = "SELECT COUNT(*) as total_images
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND cat_id NOT IN ($cat_id_sql) AND cat_id IN (".implode(", ", $cat_in).")";
$row = $site_db->query_firstrow($sql);
$total_images = $row['total_images'];
WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND c.cat_id = i.cat_id AND i.cat_id NOT IN (".implode(", ", $cat_in).")