Jump to content

So, I'm new to PHP...


soundeffects

Recommended Posts

And I'd like to ask something?

 

Someone I know told me that they had made a PHP file to show different pictures at different times of the month. But as one file. If that makes sense. I'd like to make one too, would anybody know how to go about it/where to start?

I'm not asking for you to write it all out for me, just a little push/shove/kick in the right direction?

 

Thanks.

Link to comment
Share on other sites

Say if you wanted different pictures for different months, you would so something like this....  for more information have about the php data function (http://au3.php.net/date)

 

<?php

// Get the month as a digit 0-12
$month = date("n");

switch($month) // Choose which image to display for which month by using a switch more info can be found here(http://au3.php.net/manual/en/control-structures.switch.php)
{

case $month == 1:

echo '<img src="january.jpg" alt="" />';

break;

case $month == 2:

echo '<img src="february.jpg" alt="" />';

break;

// etc....
}

?>

 

Hopefully this helps!

Link to comment
Share on other sites

otuatail: Thanks for the reply. What I was thinking was to have an image up for about 28 days of the month and have a seperate image for the other two days. Once those days were over, I'm planning on having it revert back to the original image.

 

dual_alliance: Thanks, that's pretty close to what I want. Is there any way to tweak it so the pictures change on a certain date of the month?

Link to comment
Share on other sites

Yeah you could do something like....

 

<?php

// Get the month as a digit 1-12
$month = date("n");

// Get the day as a digit 1-31
$day = date("j");

switch($month) // Choose which image to display for which month by using a switch more info can be found here(http://au3.php.net/manual/en/control-structures.switch.php)
{

case $month == 1:

if($day == 23)
{
echo '<img src="specialImage.jpg" alt="" />';
}
else
{
echo '<img src="normalImage.jpg" alt="" />';
}

break;

case $month == 2:

if($day == 13)
{
echo '<img src="specialImage.jpg" alt="" />';
}
else
{
echo '<img src="normalImage.jpg" alt="" />';
}


break;

// etc....
}

?>

 

Probably a more productive way of doing it, but it should help you :)

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.