Ich bin ein Projekt mit eckigen und PHP. Ich habe eine "Kunden" -Tabelle in meiner Datenbank. Ich versuche, alle Namen aus der Tabelle "Kunden" in einer Dropdown-Liste zu erhalten, aber es funktioniert nicht. Die Konsole zeigt momentan keine Fehler. kann jemand bitte meinen Code überprüfen?kann keine Daten mit Drop-Liste mit eckigen und PHP
Html:
<select>
<option ng-repeat="x in customersDetails track by $index" value="{{x.customer_id}}" {{x.full_name}}</option>
</select>
</div>
Controller:
"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);
?>
Das Problem in Ihrem PHP-Code $ queryResult2 ist = array(); dann? –
@ B.Kocaman Es tut mir leid, ich bin neu mit diesem was soll ich tun? – tanyaa