PHP code for a calendar using control structures
<!DOCTYPE html>
<html>
<style>
/* calendar */
h2 {background-color:#00FF7F !important;padding-top:10px
!important;padding-bottom:10px !important}
/*.calendar { border-left:1px solid
#999; }*/
.calendarday { min-height:80px; font-size:11px;
position:relative; } * html div.calendarday { height:80px; }
.calendarday:hover { background:#eceff5; }
.calendarEmpty { background:#eee; min-height:80px; } *
html div.calendarEmpty { height:80px; }
.calendarheading { background:#ccc; font-weight:bold;
text-align:left; width:120px; padding:22px; border-bottom:1px solid
#fff; border-top:1px solid #fff; border-right:1px solid #fff;
}
.dayNumber { padding:5px;
color:#000; font-weight:bold; float:right; margin:-5px -5px 0 0;
width:20px; text-align:center; }
/* shared */
.calendarday,.calendarEmpty {background-color:#eee;width:120px;
padding:22px; border-bottom:1px solid #fff; border-right:1px solid
#fff; }
</style>
<body>
<?php
/* draws a calendar of given month and year*/
function displayCalendar($month,$year){
/* draw table */
$calendar = '<table cellpadding="0" cellspacing="2"
class="calendar">';
/* table headings */
$calendarheadings =
array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
$calendar.= '<tr class="calendar-row"><td
class="calendarheading">'.implode('</td><td
class="calendarheading">',$calendarheadings).'</td></tr>';
$running_day =
date('w',mktime(0,0,0,$month,1,$year));
$days_in_month =
date('t',mktime(0,0,0,$month,1,$year));
$days_in_this_week = 1;
$day_counter = 0;
$dates_array = array();
/* row for week one */
$calendar.= '<tr class="calendar-row">';
/* print "blank" days until the first of the
current week */
for($x = 0; $x < $running_day; $x++):
$calendar.= '<td
class="calendarEmpty"> </td>';
$days_in_this_week++;
endfor;
/* keep going with days.... */
for($list_day = 1; $list_day <= $days_in_month;
$list_day++):
$calendar.= '<td
class="calendarday">';
/* add in the
day number */
$calendar.=
'<div class="dayNumber">'.$list_day.'</div>';
/** QUERY THE
DATABASE FOR AN ENTRY FOR THIS DAY !! IF MATCHES FOUND, PRINT THEM
!! **/
$calendar.=
str_repeat('<p> </p>',2);
$calendar.= '</td>';
if($running_day == 6):
$calendar.=
'</tr>';
if(($day_counter+1) != $days_in_month):
$calendar.= '<tr
class="calendar-row">';
endif;
$running_day =
-1;
$days_in_this_week = 0;
endif;
$days_in_this_week++;
$running_day++; $day_counter++;
endfor;
/* finish the rest of the days in the week */
if($days_in_this_week < 8):
for($x = 1; $x <= (8 -
$days_in_this_week); $x++):
$calendar.=
'<td class="calendarEmpty"> </td>';
endfor;
endif;
/* final row */
$calendar.= '</tr>';
/* end the table */
$calendar.= '</table>';
/* all done, return result */
return $calendar;
}
/*get the current month and Year and pass it to draw calendar
function*/
$now = new \DateTime('now');
$month = $now->format('m');
$monthName = $now->format('F');
$year = $now->format('Y');
echo "<h2 align='center'>".$monthName."
".$year."</h2>";
echo displayCalendar($month,$year);
?>
</body>
</html>
PHP code for a calendar using control structures Design Overview and Requirements As part of the...
Coding in C++ Write a program using structures to store the following weather information: - Month name - Day of month (Monday, Tuesday, etc) - High Temperature - Low Temperature - Rainfall for the day Use an the input.txt file to load the data into weather structures. Once the data for all the days is entered, the program should calculate and display the: - Total rainfall for the data - Average daily temperatures. (note: you'll need to calculate the days...
Write a php script that assigns the days of the week to an array named $days[]. Use output statements to display "The days of the week in English are: " along with the values in the $days[ ] array. Following the output statements, reassign the values in the $days[ ] array with the day of the week in French. Sunday is Dimanche, Monday is Lundi, Tuesday is Mardi. Wednesday is Mercredi. Thursday is Jeudi. Friday is Vendredi, and Saturday is Samedi....
Using the function you wrote in part 3a (refer to the bottom), write another function that, given the number of days in the month, and the day that the month starts on, the number of days that Inky Blinky Pinky and Clyde will get to play pinball in that month. The function provided will increment the day of the week to the next correct day. Function written in 3a): def pinball(dayOfWeek, dayOfMonth) : if dayOfMonth % 4 ==0: return "Pinky"...
THIS CODE SHOULD BE MODIFIED TO READ SuperMarket.dat instead of Inputting and Outputting. SuperMarket.dat Monday 4 Monday 6 Monday 2 Tuesday 3 Tuesday 2 Wednesday 3 Wednesday 5 Wednesday 7 Thursday 5 Friday 4 Friday 3 Friday 4 Saturday 8 Saturday 8 Saturday 8 Sunday 0 QUESTION: Write the control break code, including the code for the dayChange() method, in the main() method. // SuperMarket.java - This program creates a report that lists weekly hours worked // by employees of...
USING PYTHON. (Science: day of the week) Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the day of the week. The formula is h = (q + 26(m+1)//10 + k + k//4 +j//4 +5j) % 7 where - h is the day of the week (0: Saturday, 1: Sunday, 2: Monday, 3: Tuesday, 4: Wednesday, 5: Thursday, 6: Friday). - q is the day of the month. - m is the month (3: March, 4: April, ...,...
Write a C++ Program. You have a following class as a header file (dayType.h) and main(). #ifndef H_dayType #define H_dayType #include <string> using namespace std; class dayType { public: static string weekDays[7]; void print() const; string nextDay() const; string prevDay() const; void addDay(int nDays); void setDay(string d); string getDay() const; dayType(); dayType(string d); private: string weekDay; }; #endif /* // Name: Your Name // ID: Your ID */ #include <iostream>...
Need help implementing this Java class (Science: day of the week) Zeller's congruence is an algorithm developed by Christian Zeller to calculate the day of the week. The formula is h = (q + (26 * (m + 1)) / 10 + k + k / 4 + j / 4 + 5 * j) % 7 where h is the day of the week (0: Saturday, 1: Sunday, 2: Monday, 3: Tuesday, 4: Wednesday, 5: Thursday, 6: Friday). q...
Write a C# program that prints a calendar for a given year. Call this program calendar. The program prompts the user for two inputs: 1) The year for which you are generating the calendar. 2) The day of the week that January first is on, you will use the following notation to set the day of the week: 0 Sunday 1 Monday 2 Tuesday 3 Wednesday 4 Thursday 5 Friday 6 Saturday Your program should...
Write a C# program that prints a calendar for a given year. Call this program calendar. This program needs to use Switch Case in order to call the methods and format to print each month. The program prompts the user for two inputs: 1) The year for which you are generating the calendar. 2) The day of the week that January first is on, you will use the following notation to set the day of the week: ...
General Requirements: • You should create your programs with good programming style and form using proper blank spaces, indentation and braces to make your code easy to read and understand; • You should create identifiers with sensible names; • You should make comments to describe your code segments where they are necessary for readers to understand what your code intends to achieve. • Logical structures and statements are properly used for specific purposes. Objectives This assignment requires you to write...