PHP mysqli_query()数组赋值给js
将php中mysql数据库返回的数组转换成js的数组
php部分
$serve = 'localhost:3306';
$username = 'root';
$password = 'root';
$dbname = 'dabname';
$link = mysqli_connect( $serve, $username, $password, $dbname );
mysqli_set_charset( $link, 'UTF-8' );
$ming = 'select * from table';
$result = mysqli_query( $link, $ming );
js部分
var arr = eval(<?php echo json_encode(mysqli_fetch_all($result));?>);
console.log(arr);
console.log(arr.length);