Calander Basic Spript help
Posted on
16th Feb 2014 07:03 pm by
admin
hi, just starting out with PHP and have the following script:
<?php
//This gets today's date
$date =time () ;
//This puts the day, month, and year in seperate variables
$day = date('d', $date) ;
$month = date('m', $date) ;
$year = date('Y', $date) ;
//Here we generate the first day of the month
$first_day = mktime(0,0,0,$month, 1, $year) ;
//This gets us the month name
$title = date('F', $first_day) ;
//Here we find out what day of the week the first day of the month falls on
$day_of_week = date('D', $first_day) ;
//today date
$today = date('j',$date);
//Once we know what day of the week it falls on, we know how many blank days occure before it. If the first day of the week is a Sunday then it would be zero
switch($day_of_week){
case "Sun": $blank = 0; break;
case "Mon": $blank = 1; break;
case "Tue": $blank = 2; break;
case "Wed": $blank = 3; break;
case "Thu": $blank = 4; break;
case "Fri": $blank = 5; break;
case "Sat": $blank = 6; break;
}
//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year) ;
//Here we start building the table heads
echo "<table border=1 width=294>";
echo "<tr><th colspan=7> $title $year </th></tr>";
echo "<tr><td width=42>S</td><td width=42>M</td><td width=42>T</td><td width=42>W</td><td width=42>T</td><td width=42>F</td><td width=42>S</td></tr>";
//This counts the days in the week, up to 7
$day_count = 1;
echo "<tr>";
//first we take care of those blank days
while ( $blank > 0 )
{
echo "<td></td>";
$blank = $blank-1;
$day_count++;
}
//sets the first day of the month to 1
$day_num = 1;
//count up the days, untill we've done all of them in the month
while ( $day_num <= $days_in_month )
{
$day_num++;
$day_count++;
//Make sure we start a new row every week
if ($day_count > 7)
{
echo "</tr><tr>";
$day_count = 1;
}
}
//Finaly we finish out the table with some blank details if needed
while ( $day_count >1 && $day_count <=7 )
{
echo "<td> </td>";
$day_count++;
}
echo "</tr></table>";
?>
How can I add some code to highlight what the current day is?
Thanks
No comments posted yet
Your Answer:
Login to answer
188
40
Other forums
login from external site
Hi my new experience begins, Now what i am trying to do is i make three pages, login.php logout.php
Querying info from one table based on info in another
Hi, I am currently trying to make a part for my user driven website where one user can subscribe to
Escape Latin Characters
I need to escape latin characters in an xml doc. Example: "é" is escaped to "é". I thoug
DB2 for z/OS, LUW, iSeries
Hello,
In this forum a lot of threads related to other members of the DB2 family than DB2 for z/OS
Multiple Dropdown Selections
I have a form that let's a user insert a page with the ability to select categories. I want them to
php title problem
Hi,
I am having a problem managing my page title with PHP.
Currently I have my <
Getting PHP to ammended the selected in option field
Hey Guys
thanks for everyones help so far. This site and its users are oozing awesomness.
Unifying logins of two different scripts
I have two different game scripts which I want to embed on my own site. The problem is I don't want
cURL proxy
Okay here is the thing... i know how to add proxys
Code: curl_setopt($ch, CURLOPT_PROXYTYPE,
pass form variables straight to email, no database required?
hello all,
im working on this form...
http://www.adobedayevents.com/project_request/pr