MySQL insert query inside a for loop

Hello, everyone. I am a novice PHP user, but I’ve got a task to create a simple hotel booking system. It consists of several steps, each one of which is described in a separate .php files. All the files seem to be working fine, except the last one which takes all the data from the forms in previous files and inserts them into a database table. I’m trying to create a for-loop which would create a record for each day a gues is staying in a hotel. I checked all the variables by echo-ing them and they all are fine. I also tried the INSERT query without a loop and it works as well. So i guess there is something wrong with the loop. Here it is:
for ($stay_date=$checkin_unix; ; $stay_date=$stay_date+246060) {
if ($stay_date=$checkout_unix){
mysql_query(“INSERT INTO reservations VALUES(
‘date (‘d/m/Y’, $stay_date)’,



I would be very grateful for any kind of help.

I Think you are going to need a while loop, not a for

Sponsor our Newsletter | Privacy Policy | Terms of Service