Jump to content

[SOLVED] change image depending on date and time?


richiec

Recommended Posts

http://fearedwarlords.dks-gfx.com/timeframe/index.php

 

if you go there and hover over one of the images you will see that it has a date and time on there...

 

what i would like to do is...

 

if the current date and time is before the one that is showing on the hover over, for it to display a different image, with no hover over. if the current date and time is after what the image says then it displays the color image.

 

the images, time, date and name are all in the same sql table.

 

can anyone give me an example of how i would do that? because i can not find anything.

Link to comment
Share on other sites

http://fearedwarlords.dks-gfx.com/timeframe/index.php

 

if you go there and hover over one of the images you will see that it has a date and time on there...

 

what i would like to do is...

 

if the current date and time is before the one that is showing on the hover over, for it to display a different image, with no hover over. if the current date and time is after what the image says then it displays the color image.

 

the images, time, date and name are all in the same sql table.

 

can anyone give me an example of how i would do that? because i can not find anything.

 

For each of your images/queries do something like:

 

// if(strtotime('now') > strtotime("$mysql_date $mysql_time")) {
if(strtotime('now') > strtotime('2000-01-01 00:00:00')) {// compares current unix timestamp to that date
      echo "<img src='hover.jpg'>"; // do the html code with the hover
} else {
      echo "<img src='nohover.jpg'>"; // do the html code without the hover
}

Link to comment
Share on other sites

ok i did that and changed one of the images to be a later date and left the rest to be before now and it still displays the same color image.

 

this is the code..

 

$result=mysql_query($query) or die(hmm);
$num = mysql_num_rows($result);
$i=0;

echo "<div align=\"center\">";

$count = 1;
while ($i < $num) {

$name = mysql_result($result,$i,"name");
$date = mysql_result($result,$i,"date");
$time =mysql_result($result,$i,"time");
$image =mysql_result($result,$i,"image");
$image2 =mysql_result($result,$i,"image2");

if ($count == 7){ //This is how columns you would like
    echo '<br>';
    $count = 0;
}

// if(strtotime('now') > strtotime("$mysql_date $mysql_time")) {
if(strtotime('now') > strtotime('2000-01-01 00:00:00')) {// compares current unix timestamp to that date
      echo "<a href=\"#\" target=\"_parent\" title=\"$name is due on the $date at $time\"> 
<img src=\"$image\" />"; // do the html code with the hover

} else {
      echo "<img src='$image2'>"; // do the html code without the hover
}

$count++;
$i++;
}

echo '</div>';

 

 

$image is the color image, and $image2 is a grayed out version of the image.

 

did i do something wrong?

Link to comment
Share on other sites

ok i did that and changed one of the images to be a later date and left the rest to be before now and it still displays the same color image.

 

this is the code..

 

$result=mysql_query($query) or die(hmm);
$num = mysql_num_rows($result);
$i=0;

echo "<div align=\"center\">";

$count = 1;
while ($i < $num) {

$name = mysql_result($result,$i,"name");
$date = mysql_result($result,$i,"date");
$time =mysql_result($result,$i,"time");
$image =mysql_result($result,$i,"image");
$image2 =mysql_result($result,$i,"image2");

if ($count == 7){ //This is how columns you would like
    echo '<br>';
    $count = 0;
}

// if(strtotime('now') > strtotime("$mysql_date $mysql_time")) {
if(strtotime('now') > strtotime('2000-01-01 00:00:00')) {// compares current unix timestamp to that date
      echo "<a href=\"#\" target=\"_parent\" title=\"$name is due on the $date at $time\"> 
<img src=\"$image\" />"; // do the html code with the hover

} else {
      echo "<img src='$image2'>"; // do the html code without the hover
}

$count++;
$i++;
}

echo '</div>';

 

 

$image is the color image, and $image2 is a grayed out version of the image.

 

did i do something wrong?

 

$mysql_date and $mysql_time need to equal the date and time retrieved from your mysql database :P

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.