MySQL Forums
Forum List  »  PHP

Re: Date increment in INSERT loop
Posted by: Peter Brawley
Date: September 07, 2021 09:09AM

One way ...

$conn = mysqli_connect( ... );
$userid = '...'
$d = "2021-05-03';
$n = 28;
for( $i=0; $i<$n; $i++ ) {
  $q = "insert into roomsav set userid='$userid', sdate=adddate('$d' interval $i day)";
  if( !mysqli_query($conn,$q) )
    exit( $conn->error );
}

Options: ReplyQuote


Subject
Written By
Posted
September 06, 2021 09:08AM
September 07, 2021 05:38AM
Re: Date increment in INSERT loop
September 07, 2021 09:09AM
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.