Hi, guys
Right now I have dynamic input fields that would be generated by javascripts.
So if the user generates four sets of data, I'll have four sets of text fields like this.
name[] age[] height[] nationality[]
name[] age[] height[] nationality[]
name[] age[] height[] nationality[]
name[] age[] height[] nationality[]
These are the name of each input field.
So, once they are submitted, I want to INSERT them to my Mysql database. I did some research online and I found out I have to use FOREACH function to handle this dynamic input data and so I came up with the following initial codes.
$query = "INSERT INTO users (name, age, height, nationality) VALUES ";
foreach($_POST as $key => $value){
$q_parts[]='('.$value.')';
}
$query .= implode(',',$q_parts);
Am I going into the right direction? With this code, would the values of the input fields be organized accordingly for the insertion?