php - multiple entries from variable date range -


i have form on page1 has 4 inputs (name, startdate, enddate, reason).

i want add entry mysql every day date range (startdate, enddate)

i know how add mysql dont know how process of getting different dates , inserting them.

this needs automated date ranges change every time.

so 04/07/2018 - 09/07/2018 or 01/02/2017 - 02/02/2017 depending on users selection on page1.

kinda follows

$name = $_post['name'];  $startdate = $_post['startdate'];  $enddate = $_post['enddate'];  $reason = $_post['reason'];   insert taken (`name`, `date`, `reason`) values ('$name', '$date', '$reason') 

where startdate 01/01/2016 , enddate 05/01/2016 want add 5 times example

insert taken (`name`, `date`, `reason`) values ('joe bloggs', '01/01/2016', 'holiday')  insert taken (`name`, `date`, `reason`) values ('joe bloggs', '02/01/2016', 'holiday')  insert taken (`name`, `date`, `reason`) values ('joe bloggs', '03/01/2016', 'holiday')  insert taken (`name`, `date`, `reason`) values ('joe bloggs', '04/01/2016', 'holiday')  insert taken (`name`, `date`, `reason`) values ('joe bloggs', '05/01/2016', 'holiday') 

i have searched , tried many ways none work or fail.

any on matter fantastic.

create table dates ever need (see here how that).

change taken.date column date type.

then can simple bulk insert:

insert `taken` (`name`, `date`, `reason`)      select 'joe bloggs', d.`date`, 'holiday'     `dates` d     d.`date` between '2016-01-01' , '2016-01-05'; 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -