I want 6 records to be inserted using for loop

$dayNames = [];

    $dayNames = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
    // print_r($dayNames);        

    for ($i = 0; $i <= 5; $i++) {

        $data = array(
            ':st_class'     =>    $_POST["st_class"],
            ':st_section'   =>    $_POST["st_section"],
            ':from'         =>    $_POST["from"],
            ':to'           =>    $_POST["to"],
            ':day'          =>    $dayNames[$i]
        );

        // print_r($data);
        // exit;

        $object->query = "
		INSERT INTO rt_class_routine
		(class_id, section_id, time_start, time_end, day) 
		VALUES (:st_class, :st_section, :from, :to, :day)
		";
    }

I want 6 records to be instered but it saves only one with Saturday in day field.

Please resolve my problem

Since I do not know how you are talking to your database other than you have something called object my GUESS is that you are not actually issuing each query. You are overwriting the property $qbject->query each time you set it in the loop and then outside of the look you are probably calling something that executes the query.

Whatever executes the query, put it insider the loop.

Cheers! :slight_smile:
=C=