Questions about dates growing periodically and inserted into the database
用岁月换光辉
用岁月换光辉 2019-05-04 16:07:40
0
0
955

//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.



用岁月换光辉
用岁月换光辉

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template