我似乎无法解决代码中的错误 它没有真正指定任何东西告诉我错误是在PHP的第1行(这必须是假的)。 我已经仔细检查了我的sql服务器信息,它似乎是正确的, 但我在线使用的测试服务器速度非常慢,所以可能是这种情况, 加载速度不够快? (但它的deff在我的sql express管理中工作) 我非常感谢你的帮助
这是我的HTML:
<html>
<body>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"></script>
<div ng-app="myApp" ng-controller="cntrl">
<form>
Student ID: <input type="text" ng-model="id" name="id" ng-disabled="obj.idisable">
Student Name: <input type="text" ng-model="name" name="id">
<input type="button" value="{{btnName}}" ng-click="insertdata()" >
{{msg}}
</form>
<table>
<thead>
<tr>
<th>Name</th>
<th>Roll No</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="student in data">
<td>{{student.studid}}</td>
<td>{{student.studname}}</td>
<td><button ng-click="deleteStud(student.studid);">Delete</button></td>
<td><button ng-click="editStud(student.studid, student.studname);">Edit</button></td>
</tr>
</tbody>
</table>
</div>
<script>
var app=angular.module('myApp',[]);
app.controller('cntrl', function($scope,$http){
$scope.obj={'idisable':false};
$scope.btnName="Insert";
$scope.insertdata=function(){
$http.post("insert.php",{'id':$scope.id, 'name':$scope.name, 'btnName':$scope.btnName})
.success(function(){
$scope.msg="Data Inserted";
$scope.displayStud();
})
}
$scope.displayStud=function(){
$http.get("select.php")
.success(function(data){
$scope.data=data
})
}
$scope.deleteStud=function(studid){
$http.post("delete.php",{'id':studid})
.success(function(){
$scope.msg="Data Deletion successfull";
$scope.displayStud();
})
}
$scope.editStud=function(studid, studname)
{
$scope.id=studid;
$scope.name=studname;
$scope.btnName="Update";
$scope.obj.idisable=true;
$scope.displayStud();
}
});
</script>
</body>
</html>
这是我的select.php:
<?php
//database settings
include "connectdb.php";
$query="select * from student";
//$data = array();
$rs=$dbhandle->query($query);
while ($row = $rs->fetch_array()) {
$data[] = $row;
}
//print_r($data);
return json_encode($data);
?>