使用ajax和jquery final.html从db获取值

时间:2017-03-11 07:20:24

标签: javascript php jquery ajax

我尝试使用jquery获取数据库值,但它无法正常工作

代码 - final.html:http://pastebin.com/vMy5invc

api.php

<?php 
      $host = "localhost";
      $user = "root";
      $pass = "";
      $databaseName = "vhc";
      $tableName = "users";
      $con = mysql_connect($host,$user,$pass);
      $dbs = mysql_select_db($databaseName, $con);
      $data = array();
      $result = mysql_query("SELECT `id`,`name`,`email`,`location` FROM $tableName");
      while ( $row = mysql_fetch_row($result) )
        {
          $data[] = $row;
        }
      echo json_encode( $data );          

       ?>

1 个答案:

答案 0 :(得分:0)

你应该用&#34;。$ tableName替换$ tableName。&#34;

$users=User::whereNotIn('name',['admin'])->pluck('id','name');