473,509 Members | 10,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Holiday Planner

4 New Member
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
Jun 15 '07 #1
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?
Jun 15 '07 #2
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.
Jun 15 '07 #3
epots9
1,351 Recognized Expert Top Contributor
u do only want to display Monday to Friday, excluding Suturday and Sunday?
Jun 15 '07 #4
sidders
4 New Member
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.
Expand|Select|Wrap|Line Numbers
  1.     <? 
  2.  
  3.         if(isset($todo) and $todo=="submit"){
  4.         $date_value="$month/$dt/$year";
  5.         echo "mm/dd/yyyy format :$date_value<br>";
  6.         $date_value="$year-$month-$dt";
  7.         echo "YYYY-mm-dd format :$date_value<br>";
  8.             }
  9.  
  10.         $Month = $_GET['month'];
  11.         $Year = $_GET['year'];
  12.  
  13.         //echo $Month;
  14.         //echo $Year;
  15.  
  16.  
  17.         //This gets todays date
  18.          $date =time ();
  19.  
  20.         //This puts the day, month, and year in seperate variables
  21.         $day = date('d', $date); 
  22.         $month = date('m', $date); 
  23.         $year = date('Y', $date);
  24.  
  25.         //Here we generate the first day of the month
  26.         $first_day = mktime(0,0,0,$month, 1, $year); 
  27.  
  28.         //This get's us the month name
  29.         $title = date('F', $first_day); 
  30.  
  31.         //Here we find out what day of the week the first day of the month falls on
  32.         $day_of_week = date('D', $first_day); 
  33.  
  34.         echo $day_of_week;
  35.  
  36.         ?>
  37.     <html>
  38.     <body>
  39.         <form method='GET' name='Form1' action='<? $_SERVER['PHP_SELF'];?>'>
  40.     <table border="0" cellspacing="0" >
  41.         <tr><td align=left >
  42.         </select>&nbsp;&nbsp;&nbsp; 
  43.         <select name=month value=''>Select Month</option>
  44.         <option value='01'>January</option>
  45.         <option value='02'>February</option>
  46.         <option value='03'>March</option>
  47.         <option value='04'>April</option>
  48.         <option value='05'>May</option>
  49.         <option value='06'>June</option>
  50.         <option value='07'>July</option>
  51.         <option value='08'>August</option>
  52.         <option value='09'>September</option>
  53.         <option value='10'>October</option>
  54.         <option value='11'>November</option>
  55.         <option value='12'>December</option>
  56.         </select>
  57.  
  58.         </td><td align=left > 
  59.     Year(yyyy)<input type=text name=year size=4 value=2005>
  60.         <input type=submit value=Submit>
  61.     </table>
  62.         </form> 
  63.     <?
  64.  
  65.         function showMonth($month, $year)
  66.             {
  67.         $date = mktime(12, 0, 0, $month, 1, $year);
  68.         $daysInMonth = date("t", $date);
  69.         // calculate the position of the first day in the calendar (sunday = 1st column, etc)
  70.         $offset = date("w", $date);
  71.         //echo $offset;
  72.            $rows = 1;
  73.         $dateDay=cal_to_jd(CAL_GREGORIAN,date("m"),date("d"),date("Y"));
  74.         $ddate = (jddayofweek($dateDay,2));
  75.         echo $ddate;
  76.         //for($ddate = 1; $ddate <= $offset; $ddate++)
  77.         function myfunction() 
  78.               {
  79.         for($i = 1; $i != 31; $i++)
  80.         echo $ddate;
  81.               }
  82.     ?>
  83.        <h1>Displaying calendar for  <?  date("F Y", $date); ?> </h1>
  84.     <table border="1">
  85.  
  86.      <tr>
  87.      <td bgcolor="#666666"><? 
  88.         echo $_GET['action'];
  89.     ?> </td>
  90.        <?
  91.  
  92.         for($i = 1; $i <= $daysInMonth; $i++)
  93.             {
  94.     ?>
  95.      <td> 
  96.     <? 
  97.          myfunction()  ?>&nbsp;</td>
  98.     <?
  99.             }
  100.         while( ($i + $offset) <= $rows  )
  101.             {
  102.     ?>
  103.      <td></td>
  104.     <?    
  105.         $i++;
  106.         }
  107.     ?>
  108.  
  109.     </tr><tr>
  110.     <td bgcolor="#666666">&nbsp; </td>        
  111.     <?
  112.          for($day = 1; $day <= $daysInMonth; $day++)
  113.             {
  114.     ?>
  115.      <td> 
  116.     <? echo $day; ?> </td>
  117.     <?
  118.         }
  119.         while( ($day + $offset) <= $rows  )
  120.         {
  121.     ?>
  122.      <td></td>
  123.     <?    
  124.         $day++;
  125.         }
  126.     ?>
  127.     </tr>
  128.  </table>
  129.     <?
  130.         }
  131.     ?>
  132. Displaying the calendar in a page
  133. 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.
  134. For example:
  135.     <? 
  136.     showMonth($Month, $Year); // July 2005
  137.    //showMonth(1, 1980); // January 1980  
  138.   // showMonth(12, 2012); // December 2012 ?>
  139. </body>
  140. </html>
  141.  
Jun 18 '07 #5
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?
Jun 18 '07 #6
sidders
4 New Member
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.
Jun 18 '07 #7
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?
Jun 18 '07 #8
sidders
4 New Member
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.
Jun 18 '07 #9
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.

Expand|Select|Wrap|Line Numbers
  1. function buildMonth($month, $year)
  2. {
  3.   $ret = array();
  4.   for($i = 1; $i <= mcal_days_in_month($month, $year); $i++)
  5.   {
  6.     $ret[i] = date('D', mktime(0, 0, 0, $month, $i, $year));
  7.   }
  8.   return $ret;
  9. }
  10.  
Jun 18 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1502
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...
0
1929
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....
2
1271
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:...
1
14894
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...
4
2801
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)....
1
1439
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...
2
1598
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...
26
2392
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...
6
14320
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,...
0
7347
Oralloy
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,...
1
7073
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...
0
7506
tracyyun
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...
0
5656
agi2029
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,...
0
3218
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...
0
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
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 ...
1
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.