if (empty()); Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

if (empty()); Question

Post by $var »

I am trying to write a script that changes an image based on a date value in the field.
If there is no image associated with a date, I would just like to display the next image available.

Is there something that would go in here that would tell it to go to the next field if the image isn't there?

Code: Select all

if (empty($image)); {
}
thanks
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Post by seodevhead »

Well... let's say you determine which day it is by using:

Code: Select all

$current_day = date('l');  // Lowercase L
# above would set $current_day = Monday for example

If you have images called:
Monday.jpg
Tuesday.jpg
Wednesday.jpg
etc.

Then this is what you are looking for.

Code: Select all

$counter = 1;
if(empty($image))
{
$current_day = date('l')+$counter;
$counter++;
}
Of course the if statement should be in a loop.

If I am wrong, please correct me and my apologies.
User avatar
$var
Forum Contributor
Posts: 317
Joined: Thu Aug 18, 2005 8:30 pm
Location: Toronto

Post by $var »

i don't know if this would be suitable... as i think that the images will be uploaded with indefinate naming for inconsitent dates.
is there something like

if (empty()) {
disp_next_row
}


i know this isn't the case though, i check the manual.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

depends on your setup, post the code.
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Post by seodevhead »

If this is the case, then you need to provide us with some more of your code to understand what you want precisely. How is the images table set up? What determines what image is pulled depending on the date? Get back to us and we'll help you best we can!. :)
Post Reply