I want to prepare an SQL insert statement inside PHP for loop, my statement is something like this
$insert_stmt = "";
for($x=1; $x<=$all_property[duration]; $x++) {
$insert_stmt .= "INSERT INTO `schedule` VALUES ($all_property[serial], $_POST[Day$x])";
echo $insert_stmt;
mysqli_free_result($insert_stmt); // Free result set for next query
}
wherein I expect the result to be like
INSERT INTO `schedule` VALUES ($all_property[serial], $_POST[Day1] //for first loop
INSERT INTO `schedule` VALUES ($all_property[serial], $_POST[Day2] //for second loop
And so on, but I am getting error
syntax error, unexpected '$x' (T_VARIABLE), expecting ']' in schedule.php on line 163
so, if any one can help me rectify what is wrong in my query.