Jump to content

Recommended Posts

month a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31

1 puudu 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 [20] [21] 22 23 24 25 [26] 27 28 29 30 31

2 puudu 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

3 puudu 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

4 puudu 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

5 puudu 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

6 puudu 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

7 puudu 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

8 puudu 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

9 puudu 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

10 puudu 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

11 puudu 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

12 puudu 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

 

 

;

i need help .. with calculating how many days are between example:  january = 1  ; day =23 to feb =2; day 23

in php ... how can i do that

Example from the manual:

<?php

$january = new DateTime('2011-01-23');
$february = new DateTime('2011-02-23');
$interval = $february->diff($january);

// %a will output the total number of days.
echo $interval->format('%r%a total days')."\n<br />";

// While %d will only output the number of days not already covered by the
// month.
echo $interval->format('%m month, %d days');

?>


Why would you design a database like this?  Are you planning on the number of days in March changing in the near future?  Are you going to run a calendar that's different from everyone else's?

 

To my knowledge, there is no way to easily write this query.  You COULD use a very (very) long series of IF statements that progressively add 1 to a variable if the column is populated for a specific row, but you'd have to build the query itself in PHP anyway.

 

MySQL offers the DATEDIFF function, but your table is very poorly constructed...and you don't actually NEED a table to use the datediff function.

 

-Dan

Don't write your own date functions.  PHP has DateTime::diff.  MySQL has DATEDIFF.  There is absolutely no reason for you to attempt to write your own date/time functions.

 

This is how you build a calendar:

Each "event" entry has an "event date," plus a title and a description. 

 

Select all the events from a specific month you wish to display.  Sort by start date.

 

Loop through the days of the month (using PHP) and print the calendar, moving to a new row once you hit a the end of the week.  Use the PHP functions strtotime and date to determine what day of the week you're on.

 

For each day, check to see if there are any events in your result set that fall inside that day.  If so, print them.

 

You should be able to make a calendar without any hard-coded days of the month.  This MySQL table is completely unnecessary, I recommend you delete it now.

 

-Dan

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.