Jump to content

[SOLVED] Set img display quandary


samoht

Recommended Posts

Hello again,

 

I have run into a situation and was hoping someone here could help.

 

I have a little box on the right column of my site that displays the current seasons. It knows which ones to display based on my seasons table that has the season info plus a start and a end date for the season. Included in the info is a image url.

 

My code to populate the box:

 <?php
//Check What Season Should display 
$q = "SELECT Name, ImageURL FROM seasons WHERE NOW() > DateStart AND NOW() < DateEnd"; 
$result = dbQuery($q);
	while ($row = dbFetchAssoc($result)) {
  extract($row);
  echo "<img src=\"images/seasons/".$ImageURL."\" /><p><a href=\"catalog.php?g=144&season=$Name\">-$Name-</a><br />";
}

 

My CSS to display the img proper:

#seasonal img {position:absolute; bottom:0; right:0;}

 

The quandary is "What to do if there are overlapping seasons"? - This is because holidays are also being considered in my seasons table (e.g. Halloween, Thanksgiving, Christmas, fall etc.) This is because the purpose of my seasonal box is not to display the 4 seasons per say but the products that are unique or associated with seasonal events

 

Any ideas on the display of the picture problem?

 

how can I display just the first img from the loop?

 

Thanks for the help!

Link to comment
Share on other sites

Yes, but the purpose of my box is to display all the current seasonal links. So if it's November 28th and the client has set Thanksgiving to end on Nov. 31 - because he wants to run a sale on Thanksgiving Items after the holiday - but Christmas starts on Nov. 25  - they should both display in the link list - but the img for Thanksgiving should be the only one that displays.

 

FYI - the img is a background img

Link to comment
Share on other sites

I guess, any image. You could count the rows to see if there is more than one season and if not, you don't even need a loop. If there is, only do the links in the loop. Something like:

$q = "SELECT Name, ImageURL FROM seasons WHERE NOW() > DateStart AND NOW() < DateEnd"; 
$result = dbQuery($q);
$row = dbFetchAssoc($result);
extract($row);
echo "<img src=\"images/seasons/".$ImageURL."\" /><p><a href=\"catalog.php?g=144&season=$Name\">-$Name-</a><br />";
if (dbNumRows($result) > 1)
{
	while ($row = dbFetchAssoc($result)) {
  extract($row);
  echo "<p><a href=\"catalog.php?g=144&season=$Name\">-$Name-</a><br />";
}
}

 

I'm not familiar with the database functions you are using so I made up the dbNumRows() function. Switch that with whatever you would use to count how many rows are in the result.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.