私はangleとphpでプロジェクトを構築しています。私は自分のデータベースに "顧客"テーブルを持っています。ドロップリストの "Customers"テーブルからすべての名前を取得しようとしていますが、動作していません。今のところコンソールにエラーは表示されません。誰も私のコードをチェックしてくださいできますか?は、角度とPHPを使ってドロップリストでデータを取得できません。
HTML:
<select>
<option ng-repeat="x in customersDetails track by $index" value="{{x.customer_id}}" {{x.full_name}}</option>
</select>
</div>
コントローラー:
"use strict";
angular.module('dataSystem').controller('priceOfferCtrl', function($scope,$route,$location,$http)
{
$http({method:'GET', url:'api/customers-tab/get-priceOffer.php/'})
.success(function(response) {
$scope.customersDetails = response;
})
// This will log you the error code and trace, if there is an error.
.catch(function(err) {
console.log('err', err)
});
});
PHPの
<?php
header('Content-Type: text/html; charset=utf-8');
$connection = mysqli_connect('localhost','root','','hamatkin');
mysqli_query($connection,"SET character_set_client = utf8");
mysqli_query($connection,"SET character_set_connection = utf8");
mysqli_query($connection,"SET character_set_results = utf8");
if(!$connection){
die("couldnt connect".mysqli_error);
}
$customer = new Customer();
$query = "SELECT * FROM `customers``";
$queryResult = $connection->query($query);
$queryResult2 = array();
if($queryResult->num_rows>0){
while($row = $queryResult->fetch_assoc()){
$customer->customer_id = $row['customer_id']
$customer->full_name =$row['full_name']
}
}
header('Content-type:application/json');
$queryResult3 = json_encode($queryResult2);
echo json_encode($queryResult3);
?>
問題はPHPのコード$ queryResult2である=配列();それで? –
@ B.Kocaman申し訳ありませんが、私はこれで何ができるのですか? – tanyaa