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]