I have a AngularJS Function that sends an array to my PHP. But how do I go through this array in PHP and insert each value into MySQL database. SoI have the following $http post:
var data = {
"username": $scope.un,
"courses": $scope.selectedCourses
}
$http({
url: "submitCourses.php",
method: "POST",
data: data
}).success(function(response) {
$scope.courseSubmitResponse = response.resp;
});
And the $scope.selectedCourses looks like ["COEN 10", "MATH 54", "HIST 99"] when sent over. So how could I insert each of these values into my database? Is there a way I can assign a php variable to the array, then do a for loop of that php variable? Your help is greatly appreciated.