Jump to content

Set up a form based on dates


smerny

Recommended Posts

I want to create a two week time sheet form that fills out the Day Of Week and Date for all days within two inputted dates.

 

The dates will be the first of the month through the 15th of the month, and then the 16th through the end of the month (could be 28,29,30 or 31)... it will skip sundays

 

For example, if someone put the start date of 11/1/2009 and an end date of 11/15/2009... I'm going to want a form that looks like:

 

Day of WeekDateInOutLunchTotal

MONDAY11/2<input><input><input>0

TUESDAY11/3<input><input><input>0

WEDNESDAY11/4<input><input><input>0

THURSDAY11/5<input><input><input>0

FRIDAY11/6<input><input><input>0

SATURDAY11/7<input><input><input>0

Weekly Total:0

[/td]

MONDAY11/9<input><input><input>0

TUESDAY11/10<input><input><input>0

WEDNESDAY11/11<input><input><input>0

THURSDAY11/12<input><input><input>0

FRIDAY11/13<input><input><input>0

SATURDAY11/14<input><input><input>0

Weekly Total:0

0

 

I was thinking that there would first be a form in which the user can enter the start and end date, then it brings up this form in which the days and dates are automatically lined up... and they can enter their hours into text input boxes (represented by <input>)... possibly have a javascript that will calculate on the fly.... but then after the user enters their hours and hits the submit key, it will show the form with all the numbers (no input) that can be printed out.

 

My first question is... how can I get it to figure out the days to dates and go through the dates within the given range? Remember that sometimes this will actually span 3 weeks, and in that case I would like it to look like..

 

MONDAY

TUESDAY

WEDNESDAY  11/1  [inputs]

THURSDAY      11/2  [inputs]

FRIDAY          11/3  [inputs]

SATURDAY    11/4  [inputs]

 

MONDAY  11/6  [inputs]

TUESDAY  11/7  [inputs]

WEDNESDAY  11/8  [inputs]

THURSDAY      11/9  [inputs]

FRIDAY          11/10  [inputs]

SATURDAY    11/11  [inputs]

 

MONDAY  11/13  [inputs]

TUESDAY  11/14  [inputs]

WEDNESDAY 11/15  [inputs]

THURSDAY

FRIDAY

SATURDAY

 

 

hopefully this all makes sense...

Link to comment
https://forums.phpfreaks.com/topic/181196-set-up-a-form-based-on-dates/
Share on other sites

Anyone have any ideas?

 

I'm thinking the body of the loop will be something like:

 

$date = $startDate;
$i = 1;
while($date <= $endDate)
{
   echo "<tr><td>". dayOfWeek($date) ."</td>
   <td>". $date ."</td>
   <td><input type='text' name='".$in['i']."'></td>";

...etc...

   $date ++;
   $i ++;
}

 

probably not doing it right or the best way... not really sure how i should do it... but i figured this might give an idea of what i am trying to do

I am looking for an almost the same solution.

 

But I am grouping it by a customers postcode they enter (the first part before the space) in UK postcodes.

 

Then grouping and adding up all post codes with that month.

 

However just using select boxes for every month in years though aswell so 12 months for x number of years.

 

Januarys results for 2009

Zone code:        Sold:

HG2                  £22,000

HG4                  £10,000

 

February results for 2010

HG1                  £21,000

HG4                  £25,000 etc

 

I have the following SQL but the dates as you can see are completely static, not what we require:

 

SELECT LEFT( `b_zipcode`, INSTR( `b_zipcode`, ' ')) AS zone, SUM(`total`) AS total, COUNT(*) AS sales FROM `xcart_orders` WHERE DATE BETWEEN 1254414901 AND 1257006901 GROUP BY zone

 

There is a problem though, there is possible going to have to be some conversion, as you can see the DATE BETWEEN is a Unix Timestamp, so its going to have to be converted.

 

Any help is greatly appreciated.

 

Thanks in advance,

Jeremy.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.