PHP 文件:
<?php
require 'JSON.php'; // JSON.php
try
{
$connection = mysql_connect("localhost", "root", "autoset") or die("Could not connect: " . mysql_error());
mysql_query("SET NAMES utf8", $connection);
mysql_select_db(test, $connection);
$sql = "select * from Evaluation";
$sth = mysql_query($sql) or die("Query error: " . mysql_error());
// JSON
$json = new Services_JSON();
$rows = array();
while ($r = mysql_fetch_assoc($sth))
{
$rows[] = $r;
}
$output = $json->encode($rows);
echo $output;
mysql_close($connection);
}
catch (Exception $e)
{
echo $e->getMessage();
// Note: Log the error or something
}
?>
这是我的 JSON 结果:
[{"ENTERPRISE":"22","PERIOD":"53","EPS":"54","STOCKPRICE":"24","PER":"33"}]
我怎样才能得到没有像这样的列名的字段?
[22, 55, 54, 24, 33]