Kyle Caudle
New member
I am having trouble starting this program, this is the assignment description......
Month and Date Assignment
Using the getdate() function and some if statements, write a PHP script that will do exactly what you see at the top of this page: Print the day of week, month name, day of month, and year, and in front of that insert an image for the current month!
The image files are available below - simply right-click on each one and select the option to "save image" from the context menu. The files are named january.jpg, february.jpg, march.jpg, april.jpg, may.jpg, june.jpg, july.jpg, august.jpg, september.jpg, october.jpg, november.jpg, and december.jpg. Copy them to your wwwroot\www folder on your pendrive, and to you www folder on your course homepage. Then you'll be able to reference them in an image tag as so:
<img src="january.jpg" alt="january" />
Alternatively, you can just reference the images from the school server. If you do so, you'll have to use the full URL in your img tag, as follows:
<img src="http://ed41.com/cis105/months/january.jpg" alt="january" />
In addition to making your program work for today's date, you will also need to make it work for any given date. How will we go about this?
One solution is to use an optional querystring. Write your script so that if a querystring is appended when the program is called, it will use the date information from the querystring. Otherwise, it should use today's date.
For example, if I run your script with a querystring like so:
http://cis3.elgin.edu/loginname/monthanddate.php?m=5&d=24&y=2017
Your program would use the date 5/24/2017 instead of today's date. But if the querystring is not there:
http://cis3.elgin.edu/loginname/monthanddate.php
Then your program should just use today's date instead.
this is the code i have so far.....
<?php
if (isset($_GET['m']) AND isset($_GET['d']) AND isset($_GET['y']))
{
$monthnumber = $_GET['m'];
$dayofmonth = $_GET['d'];
$year = $_GET['y'];
$timestamp = mktime(0,0,0,$monthnumber,$dayofmonth,$year);
$now = getdate($timestamp);
}
else
{
$now = getdate();
$monthnumber = $now['mon'];
$dayofmonth = $now['mday'];
$year = $now['year'];
}
?>
Month and Date Assignment
Using the getdate() function and some if statements, write a PHP script that will do exactly what you see at the top of this page: Print the day of week, month name, day of month, and year, and in front of that insert an image for the current month!
The image files are available below - simply right-click on each one and select the option to "save image" from the context menu. The files are named january.jpg, february.jpg, march.jpg, april.jpg, may.jpg, june.jpg, july.jpg, august.jpg, september.jpg, october.jpg, november.jpg, and december.jpg. Copy them to your wwwroot\www folder on your pendrive, and to you www folder on your course homepage. Then you'll be able to reference them in an image tag as so:
<img src="january.jpg" alt="january" />
Alternatively, you can just reference the images from the school server. If you do so, you'll have to use the full URL in your img tag, as follows:
<img src="http://ed41.com/cis105/months/january.jpg" alt="january" />
In addition to making your program work for today's date, you will also need to make it work for any given date. How will we go about this?
One solution is to use an optional querystring. Write your script so that if a querystring is appended when the program is called, it will use the date information from the querystring. Otherwise, it should use today's date.
For example, if I run your script with a querystring like so:
http://cis3.elgin.edu/loginname/monthanddate.php?m=5&d=24&y=2017
Your program would use the date 5/24/2017 instead of today's date. But if the querystring is not there:
http://cis3.elgin.edu/loginname/monthanddate.php
Then your program should just use today's date instead.
this is the code i have so far.....
<?php
if (isset($_GET['m']) AND isset($_GET['d']) AND isset($_GET['y']))
{
$monthnumber = $_GET['m'];
$dayofmonth = $_GET['d'];
$year = $_GET['y'];
$timestamp = mktime(0,0,0,$monthnumber,$dayofmonth,$year);
$now = getdate($timestamp);
}
else
{
$now = getdate();
$monthnumber = $now['mon'];
$dayofmonth = $now['mday'];
$year = $now['year'];
}
?>