无法显示特定的"客户"来自"客户"的详细信息表

时间:2016-07-20 13:47:18

标签: php angularjs

我正在使用angular和php建立一个项目,我试图展示特定的"客户"细节,它不适合我,我不知道在sql Query上写什么,而不是' 82'。有人可以帮忙吗?我想在页面上显示特定的客户详细信息。

这是我的代码:

Customer.php

<?php
class Customer {

  private $table_name = "customers";

  public $customer_id;
  public $kind_Of_Customer;
  public $full_name;
  public $id;
  public $city;
  public $address;
  public $phone;
  public $phone_2;
  public $email;
  public $fax;
  public $referrer;
  public $comments;


}

?>

readCustomer.php

<?php header('Content-Type: text/html; charset=utf-8');

    include_once 'Customer.php';
    $con = mysqli_connect('localhost','root','','hamatkin');

    mysqli_query($con,"SET character_set_client = utf8");
    mysqli_query($con,"SET character_set_connection = utf8");
    mysqli_query($con,"SET character_set_results = utf8");


    $customer = new Customer();


    $query = "SELECT customer_id, kind_Of_Customer, full_name, id, city, address,phone,phone_2 FROM customers where customer_id= ";
    $result = $con->query($query);
    $row = $result->fetch_assoc();
    // reset the result resource
    // mysql_data_seek($result, 0);
    if( $result->num_rows!=0)
    {


        $customer->kind_Of_Customer = $row['kind_Of_Customer'];
        $customer->full_name =$row['full_name'];
        $customer->id = $row['id'];
        $customer->city = $row['city'];
        $customer->address = $row['address'];
        $customer->phone = $row['phone'];
        $customer->phone_2 = $row['phone_2'];

    }
    echo '<pre>'; print_r($customer); die; 
    $res = json_encode($customer);
     echo $res;

?>

CustomerCardDetailsCtrl.js

"use strict";
angular.module('dataSystem').
controller('customerCardDetailsCtrl', function($scope, $http ,$routeParams, $location) {

  var customer_id = $routeParams.customer_id;
  $scope.customer_id = customer_id;
  var data = $.param({
    customer_id: customer_id
});

var config = {
    headers : {
        'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
    }
}


  $http.get('api/readCustomer.php/' + customer_id,data,config ).

  success(function(data){
    $scope.customerDetails = data;
    console.log($scope.customerDetails);
  }).
  error (function (error) {
    console.log(error);
  });
});

这是控制台显示的内容:

<pre>Customer Object
(
    [table_name:Customer:private] => customers
    [customer_id] => 
    [kind_Of_Customer] => פרטי
    [full_name] => דניס גרינברג
    [id] => 307074252
    [city] => נצרת עילית
    [address] => ניצן 12 דירה 2
    [phone] => 545916274
    [phone_2] => 523459878
    [email] => 
    [fax] => 
    [referrer] => 
    [comments] => 
)

0 个答案:

没有答案