MySQL Forums
Forum List  »  PHP

Date increment in INSERT loop
Posted by: Pete Ace
Date: September 06, 2021 09:08AM

I have the code below in a php file and it works successfully. The roomsav mysql table gets the inserts and here is that table:

userid | sdate
TL2-0001 2021-05-03
TL2-0001 2021-05-03
TL2-0001 2021-05-03

All I want to do is increment the date by one day in the loop so the roomsav table looks like this:

userid | sdate
TL2-0001 2021-05-03
TL2-0001 2021-05-04
TL2-0001 2021-05-05

I have tried everything including throwing computer out of window. Would appreciate any help. Thanks


$userid = $_POST["userid"];
$sdate = $_POST["sdate"];
$qty = 3;

for($i=0; $i< $qty; $i++)
$sql = "INSERT INTO roomsav (userid, sdate) VALUES('".$userid."','".$sdate."')";
$result = mysqli_query($conn, $sql);

Options: ReplyQuote

Written By
Date increment in INSERT loop
September 06, 2021 09:08AM
September 07, 2021 05:38AM
September 08, 2021 02:30AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.