4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
September 20, 2018, 04:06:03 PM

Login with username, password and session length
Search:     Advanced search
4images is now on facebook. Click here and become a fan!
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Modifications / Modifikationen
| |-+  Mods & Plugins (Requests & Discussions) (Moderators: mawenzi, Rembrandt)
| | |-+  which command :cat has no images?
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: which command :cat has no images?  (Read 1889 times)
ilaslan
Newbie
*
Offline Offline

Posts: 44

Thank You
-Given: 15
-Receive: 0


View Profile
« on: January 20, 2011, 01:40:58 AM »

hello
i have this code

1
2
3
4
5
$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 i.cat_id = 
$cat_random AND c.cat_id = i.cat_id
        ORDER BY "
.$selection[$cnt]." DESC, ".$selection_alt[$cnt];

this code is changed from mini top mod
but i have a small problem. some categories has no images. and in this cod $cat_random is random categories.

so there is a problem for me

so i need above in this code like
1
if ( $cat_random category has no images ) {  ..... }

ty all
Logged
V@no
If you don't tell me what to do, I won't tell you where you should go :)
Administrator
4images Guru
*****
Offline Offline

Posts: 17849

Thank You
-Given: 47
-Receive: 577

mmm PHP...


View Profile WWW
« Reply #1 on: January 20, 2011, 01:58:30 AM »

Assuming you have your category ID stored in $cat_id variable, then you can use this simple check:
1
2
3
4
if (!$cat_cache[$cat_id]['num_images'])
{
// your code here, this category has no images
}

Follow members gave a thank to your post:
ilaslan

For this post, 1 member gave a thank you!
Logged

Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.112 seconds with 22 queries.
Post your comments here