//Get a (string character time), b (number of times) from the form.
$b=$_POST['b']; //Number of times
$a = $_POST['a']; //Date
$d = strtotime ($a); //Convert string time to timestamp.
//The database is simple in design, automatically growing the three fields id, a, and b. The connection code is omitted.
for($i = 0; $i < $b; $i ){ //Use a loop to perform b times,
$c = date('Y-m-d',$ d $i*7*24*60*60);
$value ="(null,'$c','$b')";
$sql = "INSERT INTO test (id,a,b) VALUES ".$value;
}
Question: Logically speaking, if you loop 4 times, you should insert four dates with equal differences of 7 days into the database value, but actually only inserts a date passed by the form.
I just learned PHP not long ago, and suddenly thought of this problem. When I encountered a problem, I wanted to figure it out. I studied it for a long time, and when I had no other choice, I learned from the great gods.