如何使用Angular显示PHP MySQL查询的输出

时间:2017-04-22 09:12:16

标签: php mysql angular

我编写了MySQL查询来从表中获取大量记录。 我对角度js很新,我不知道如何将它的输出显示到Angular js中。 请仔细检查下面的PHP和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 个答案:

答案 0 :(得分: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