products are inserted successfully but cant show the products from the database it doesn't shows any erro...
this is my main.html page At first there are some problems in the in the angularjs function then i change the function from Success() to then() then the value insert work but now couldn't load the data from the database and show it
<!DOCTYPE html>
<html>
<head>
<title>Office Essentials</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<h2>Office Essentials</h2>
<div ng-app="myApp" ng-controller="cntrl">
<form>
Product Name:<br>
<input type="text" ng-model="name" name="name"><br>
Quantity:<br>
<input type="text" ng-model="quantity" name="quantity"><br>
Price:<br>
<input type="text" ng-model="price" name="price"><br>
Details:<br>
<textarea ng-model="details" name="details"></textarea>
<br><br>
<input type="submit" ng-click="insertData()" value="Submit">
<br><br>
<input type="submit" ng-click="displayProduct()" value="Show">
{{msg}}
</form>
this is for showing the products from the database
<table border="1">
<tr>
<th>Id</th>
<th>Product Name</th>
<th>Quantity:</th>
<th>Price</th>
<th>Details</th>
<th>Status</th>
</tr>
<tr ng-repeat="product in data">
<td>{{product.id}}</td>
<td>{{product.name}}</td>
<td>{{product.quantity}}</td>
<td>{{product.price}}</td>
<td>{{product.details}}</td>
<td>{{product.status}}</td>
</tr>
</table>
</div>
this is the sqript i also used in main.html page
<script >
var app=angular.module('myApp',[]);
app.controller('cntrl',function($scope,$http){
$scope.insertData = function(){
$http.post("insert.php",
{
'id':$scope.id,
'name':$scope.name,
'quantity':$scope.quantity,
'price':$scope.price,
'details':$scope.details
})
.then(function onSuccess(){
$scope.msg = "data Inserted";
})
}
$scope.displayProduct=function(){
$http.get("select.php")
.then(function onSuccess(data){
$scope.data=data
})
}
});
</script>
</body>
</html>
this is my select.php page
<?php
include "connectdb.php";
$query = "SELECT * FROM officeessentials";
$result=$dbhandle->query($query);
while($row = $result->fetch_assoc()){
$data[]->$row;
}
print json_encode($data);
?>