I need one help for inserting array of data into database using PHP,MySQL and angular.js.Let me to explain my code.Suppose i have the below set of data which will insert into database.
$scope.listOfData=[
0:{'name':raj,'email':[email protected],'rollno':11,'subject`:abc},
1:{'name':raja,'email':[email protected],'rollno':13,'subject`:ab},
2:{'name':raja1,'email':[email protected],'rollno':113,'subject`:anb},
....................................................................
.....................................................................
20:{'name':raja1,'email':[email protected],'rollno':113,'subject`:anb},
];
I have 20 numbers of data in one object and i have only 4 field in database (i.e-name,email,rollno,subject
).When user will click on submit button these 20 nos of data will insert in DB in 20 rows.Here i need how it can be done in php. In this below code i am declaring the submit function.
$scope.addData=function(){
$http({
method:'POST',
url: "php/timetable/addTimeTable.php",
data:$scope.listOfTimeData,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
}).then(function successCallback(response){
//Success callback
},function errorCallback(response) {
//Error callback
});
};
Here i need how i will pass the all data to php file and insert all data in Mysql (Lets say table name-db_user
) DB at a time in a loop.Please help me.
$scope.listOfData
is invalid.listOfData
.But my requirement is something else.