Hi, I am trying to build a holiday planner and need to be able to overcome a problem with my output with the dates. I have manipulated a calendar script to output days of the month in columns, (1 2 3 4 5 6 etc) This works fine when the month is input it shows exact days for that month. What I cannot do is repeat this for the days of the month ie M T W T F and so on. Does anyone have any
1 2 3 4 5
idea how I can relove this issue.
Regards Sid
9 2405 pbmods 5,821
Recognized Expert Expert
Heya, sidders. Welcome to TSDN!
This works fine when the month is input it shows exact days for that month. What I cannot do is repeat this for the days of the month ie M T W T F and so on.
I'm not sure I understand what you're asking. Do you want to output day-of-the-week headers for your calendar? Or do you need to determine which day of the week a given date is?
Motoma 3,237
Recognized Expert Specialist
PHP has built in functions for dealing with dates, including the ability to get the day of the week.
epots9 1,351
Recognized Expert Top Contributor
u do only want to display Monday to Friday, excluding Suturday and Sunday?
Hi again, well what I am looking for is similar to the normal calendar output which shows S M T W T F S, however instead of dropping to the next row I need it to continue along the columns until it reaches the end of the month so the table will look like S M T W T F S S M T W T F S S M T W T F S etc. I have the columns of numbers but not the day headers above. I have posted some code below as to where my problem lies. The code below is just the basic structure, for obvious reasons I have stripped out all the SQL
Thanks in advance Sidders. -
<?
-
-
if(isset($todo) and $todo=="submit"){
-
$date_value="$month/$dt/$year";
-
echo "mm/dd/yyyy format :$date_value<br>";
-
$date_value="$year-$month-$dt";
-
echo "YYYY-mm-dd format :$date_value<br>";
-
}
-
-
$Month = $_GET['month'];
-
$Year = $_GET['year'];
-
-
//echo $Month;
-
//echo $Year;
-
-
-
//This gets todays 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 get's 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);
-
-
echo $day_of_week;
-
-
?>
-
<html>
-
<body>
-
<form method='GET' name='Form1' action='<? $_SERVER['PHP_SELF'];?>'>
-
<table border="0" cellspacing="0" >
-
<tr><td align=left >
-
</select>
-
<select name=month value=''>Select Month</option>
-
<option value='01'>January</option>
-
<option value='02'>February</option>
-
<option value='03'>March</option>
-
<option value='04'>April</option>
-
<option value='05'>May</option>
-
<option value='06'>June</option>
-
<option value='07'>July</option>
-
<option value='08'>August</option>
-
<option value='09'>September</option>
-
<option value='10'>October</option>
-
<option value='11'>November</option>
-
<option value='12'>December</option>
-
</select>
-
-
</td><td align=left >
-
Year(yyyy)<input type=text name=year size=4 value=2005>
-
<input type=submit value=Submit>
-
</table>
-
</form>
-
<?
-
-
function showMonth($month, $year)
-
{
-
$date = mktime(12, 0, 0, $month, 1, $year);
-
$daysInMonth = date("t", $date);
-
// calculate the position of the first day in the calendar (sunday = 1st column, etc)
-
$offset = date("w", $date);
-
//echo $offset;
-
$rows = 1;
-
$dateDay=cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y"));
-
$ddate = (jddayofweek($dateDay,2));
-
echo $ddate;
-
//for($ddate = 1; $ddate <= $offset; $ddate++)
-
function myfunction()
-
{
-
for($i = 1; $i != 31; $i++)
-
echo $ddate;
-
}
-
?>
-
<h1>Displaying calendar for <? date("F Y", $date); ?> </h1>
-
<table border="1">
-
-
<tr>
-
<td bgcolor="#666666"><?
-
echo $_GET['action'];
-
?> </td>
-
<?
-
-
for($i = 1; $i <= $daysInMonth; $i++)
-
{
-
?>
-
<td>
-
<?
-
myfunction() ?> </td>
-
<?
-
}
-
while( ($i + $offset) <= $rows )
-
{
-
?>
-
<td></td>
-
<?
-
$i++;
-
}
-
?>
-
-
</tr><tr>
-
<td bgcolor="#666666"> </td>
-
<?
-
for($day = 1; $day <= $daysInMonth; $day++)
-
{
-
?>
-
<td>
-
<? echo $day; ?> </td>
-
<?
-
}
-
while( ($day + $offset) <= $rows )
-
{
-
?>
-
<td></td>
-
<?
-
$day++;
-
}
-
?>
-
</tr>
-
</table>
-
<?
-
}
-
?>
-
Displaying the calendar in a page
-
To display it in a HTML page, you just need to include a call to the showMonth() function, passing the desired month and year as paramters.
-
For example:
-
<?
-
showMonth($Month, $Year); // July 2005
-
//showMonth(1, 1980); // January 1980
-
// showMonth(12, 2012); // December 2012 ?>
-
</body>
-
</html>
-
Motoma 3,237
Recognized Expert Specialist
I am sorry, but I couldn't entirely follow what you were trying to do with your code. Could you please elaborate on what you are trying to do, as well as give the errors you are receiving and detail what is going wrong?
Hi ok sorry if it a little bit unclear, I will try to get this a simple as possible. A normal calendar out puts 7 days then adds the rows accordingly. I want the planner to show the month dates in line like my code already does. What I want and cannot yet do is to show the day above the day number so for instance June the 1st would be F(Friday) above the 1 and then so forth until S(Saturday) above the 30 in the column. Hope that explains it a little more.
pbmods 5,821
Recognized Expert Expert
So you want to be able to create a calendar with != 7 columns? Or put another way, you want to be able to put every single day of a month on one row? Is this correct?
So you want to be able to create a calendar with != 7 columns? Or put another way, you want to be able to put every single day of a month on one row? Is this correct?
Yes that is correct, what it will be able to do is print a list of names that have holidays in that month I can then cross reference graphically the days people overlap with holidays similar to a gantt chart.
Motoma 3,237
Recognized Expert Specialist
Hi ok sorry if it a little bit unclear, I will try to get this a simple as possible. A normal calendar out puts 7 days then adds the rows accordingly. I want the planner to show the month dates in line like my code already does. What I want and cannot yet do is to show the day above the day number so for instance June the 1st would be F(Friday) above the 1 and then so forth until S(Saturday) above the 30 in the column. Hope that explains it a little more.
The following code returns an associative array for the month you specify. The array index is the day of the month, and the value is the three letter representation of the day of the week. -
function buildMonth($month, $year)
-
{
-
$ret = array();
-
for($i = 1; $i <= mcal_days_in_month($month, $year); $i++)
-
{
-
$ret[i] = date('D', mktime(0, 0, 0, $month, $i, $year));
-
}
-
return $ret;
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Michele |
last post by:
Hi all,
There's a web-based project I'm working on, which my boss insists
should be implemented as a java web service: I know Java, but I'm a
complete newcomer to web services, so I would badly...
|
by: Florida Draw |
last post by:
------=_NextPart_000_0012_1D5428A2.65C196F8
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
Sign-up for the FREE Holiday Giveaway Draw
You must register to be eligible for the draw....
|
by: Chris Travers |
last post by:
Hi all;
I suspect I know what the answer here is, but I thought I would ask
anyway. How transparent are SQL language functions from the planner's
perspective? For example if I create a table:...
|
by: Chris Strug |
last post by:
Hi,
As something of a pet project, I'm looking to develop a tool to track
employee holiday (or vacation for those of us in the US) for my company -
good for the company (if I get something...
|
by: Fabrizio |
last post by:
HI,
I need to create a form that shows a planner (with
employees and working days ) where i can use a different
colors for "busy" days and "available" days (i'll read
the data from a Database)....
| |
by: Martin Marques |
last post by:
I was reading the section about Planner Method Configuration, and I just don't
get why all the options have this message: "This is used for debugging the
query planner". Are they all debugging...
|
by: Ed L. |
last post by:
The planner is choosing a sequential scan for my query. I am trying
to understand why since it is clearly not the fastest choice, and
what the proper tuning dial is to adjust here. Here's the...
|
by: Yeah |
last post by:
I have a web site which changes the header logo based on the upcoming
holiday.
For example, from December 10th to 25th, XMAS.JPG is displayed. From October
20th to 31st, HALLWEEN.JPG is...
|
by: Jana |
last post by:
Greetings Access Gurus! I am working on an app to send batch
transactions to our bank, and the bank requires that we place an
effective date on our files that is 'one business day in the future,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |