2017-04-22 216 views
1

我已經寫了MySQL查詢來從表中獲取一些記錄。 我對angular js非常陌生,我不知道如何將它的輸出顯示到Angular js中。 請檢查下面的PHP和MySQL查詢。如何顯示PHP的輸出使用Angular查詢MySQL查詢

<?php 
 

 
include("../include/connect.php"); 
 

 
$sql="SELECT clientDB_Status FROM ms_approach_clients where clientDB_Status='Lead-Successful'"; 
 

 
if ($result=mysqli_query($con,$sql)) 
 
    { 
 
    // Return the number of rows in result set 
 
    $rowcount=mysqli_num_rows($result); 
 
    printf("Result set has %d rows.\n",$rowcount); 
 
    // Free result set 
 
    mysqli_free_result($result); 
 

 
    } 
 

 
mysqli_close($con); 
 
?>

+1

對角的入門教程似乎是理想的地方從這裏開始。教程將介紹如何創建AJAX請求並處理響應。 – David

回答

1

,您可以嘗試。

<?php 

include("../include/connect.php"); 

$sql="SELECT clientDB_Status FROM ms_approach_clients where clientDB_Status='Lead-Successful'"; 

if ($result=mysqli_query($con,$sql)) 
    { 
    // Return the number of rows in result set 
    $rowcount=mysqli_num_rows($result); 
    printf("Result set has %d rows.\n",$rowcount); 
    // Free result set 
    $data = array(); 

while ($row = mysqli_fetch_array($result)) { 
    $data[] = $row; 
} 
    print json_encode($data); 


    } 

mysqli_close($con); 
?> 

你可以看到例如鏈接

http://stackoverflow.com/questions/26229382/how-to-display-data-from-mysql-using-angular-js-php