Skip to content
Advertisement

Date range loop into bbdd

I want to make different tables from 2 variables: start date and end date.

Example: input start= 05/07/2022 input end= 07/07/2022

so, when I submit the form I want this result:

ddbb: id:01 05/07/2022 id:02 06/07/2022 id:03 07/07/2022

I tried this but I got the dates displace, like this:

id:01 06/07/2022 id:02 07/07/2022 id:03 08/07/2022

This is the code:

JavaScript

Advertisement

Answer

It’s because you increased the date by 1 day even before you inserted it into the database. If you want the first value to be the start date, insert it, and then increment it afterwards.

For example:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement