vendredi 14 mai 2021

Can't get all dates between two dates php

This scripts needs to collect the data from the previous site and needs to send the data to my database:

<?php
$user = $_POST["user"];
$begindate= $_POST["begindate"];
$enddate= $_POST["einddatum"];
$connect = new mysqli("localhost", "root", "", "shit");

if ($begindate== $enddate) {
    $sql = "INSERT INTO usershit (user,date) VALUES ('$user','$begindate')";
    mysqli_query ($connect, $sql);
} elseif ($begindate!= $enddate){
do {
    $begindate= strtotime('+1 day',$begindate); 
    $sql = "INSERT INTO usershit (user,date) VALUES ('$user','$begindate')";
    mysqli_query ($connect, $sql);
} while ($begindate< $enddate);
}
?>

If u know how to fix it with something else than do while it's fine as well.

Aucun commentaire:

Enregistrer un commentaire