【发布时间】:2017-02-15 15:17:36
【问题描述】:
我的查询搜索餐厅数据库中的所有菜肴。
<?php
include('base.php');
$data = array();
$result = mysql_query("SELECT nombre FROM platos WHERE tipo = 'principal'",$connect);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_assoc($result)){
$data[] = $row;
}
} else {
echo "0 results";
};
echo json_encode($data);
mysql_close($connect);
?>
然后我在角度代码上调用它:
$http({
method: 'GET',
url: '../../php/getDishesPrincipal.php'
}).then(function successCallback(response) {
$scope.principals = response.data;
}, function errorCallback(response) {
$scope.principals = 'No Response';
});
好吧,最后我把它打印在我的 html 代码上:
<div id="agregarpedido_table_item" ng-repeat="principal in principals">
<p id="agregarpedido_table_item_p">{{principal.nombre}}</p>
<div id="agregarpedido_table_item_command">
<p>{{principal.cant}}</p>
<div class="selectors">
<input type="button" value="+" ng-click="principal.cant = principal.cant + 1">
<input type="button" value="-" ng-click="principal.cant = principal.cant - 1">
</div>
</div>
问题是,当我的数据库中有超过 2 个结果与tipo: principal 匹配时,html 会消失并且不显示任何内容。最糟糕的是,控制台不会像正常一样抛出任何错误。有什么想法吗?
【问题讨论】:
标签: php html mysql angularjs angularjs-ng-repeat