【发布时间】:2017-06-05 22:53:28
【问题描述】:
晚上好!
我从数据库中获取数据时遇到问题。
有项目 Drupal+AngularJS。
如果没有 Drupal,我可以使用 PHP for Angular 从 MySQL 获取数据:
在文件 index.php 中:
`...
var app = angular.module("myapp", []);
app.controller("usercontroller", function ($scope, $http) {
$scope.displayData = function () {
$http.get("select.php")
.success(function (data) {
$scope.names = data;
});
}
});`
在select.php文件中:
<?php
//select.php
$connect = mysqli_connect("localhost", "root", "root", "testing");
$output = array();
$query = "SELECT * FROM tbl_user";
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_array($result))
{
$output[] = $row;
}
echo json_encode($output);
}
?>
但是,我怎样才能用 Drupal 做到这一点?如何创建像 select.php 这样的页面? 我不明白,请帮帮我))
谢谢大家!
【问题讨论】:
-
我尝试在示例 page-programatically 之后添加一个页面,但没有成功
GET testmapapi.hm:8888/select.tpl.php 403 (Forbidden)
标签: php mysql angularjs drupal-7