如何创建
[{ "Date" : "2013.01" , "Target" : 120 , "Reach" : 150 , "Change" : 180 } ,
{“日期”:“2013.02”,“目标”:120,“到达”:150,“更改”:180}]
由于图表需要数据,因此从进入JSON?感谢你 由于图表需要数据,因此从此进入JSON?感谢你 由于图表需要数据,因此从此进入JSON?谢谢你
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>www</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
P { FONT-SIZE: 8pt; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial}
TD { FONT-SIZE: 8pt; COLOR: #000000; FONT-FAMILY: Verdana, Tahoma, Arial}
-->
</style>
</head>
<body>
<?php
/*
VIEW-PAGINATED.PHP
Displays all data from 'Admin' table
This is a modified version of view.php that includes pagination
*/
// connect to the database
include('connect-db.php');
// log record
$Time = time().'.'.$extension;
$Log = 'Admin';
$IP = $_SERVER['REMOTE_ADDR'];
$query="INSERT INTO Adminlog (ID, Log, Time, IP)VALUES ('NULL', '".$Log."',
'".$Time."', '".$IP."')";
mysql_query($query) or die ('Error updating database');
print
( '<div align="left">
</div>' );
$result = mysql_query("SELECT * FROM Admin WHERE Student='1221'")
or die(mysql_error());
{
echo "<a href='rtbr.php?page=$I'>$I</a> ";
}
echo "[";
echo "<br>";
while ($row = mysql_fetch_array($result)) {
echo "<td>" . " { "
. " "Date" " . " : " . " "2013.01" " . " , "
. " "Target" " . " : " . $row["SubjectMEScore"] . " , "
. " "Reach" " . " : " . $row["SubjectEEScore"] . " , "
. " "Change" " . " : " . $row["SubjectCCScore"] . " } " . " , "
. "</td>";
echo "<br>";
echo "<td>" . " { "
. " "Date" " . " : " . " "2013.02" " . " , "
. " "Target" " . " : " . $row["SubjectMEScore"] . " , "
. " "Reach" " . " : " . $row["SubjectEEScore"] . " , "
. " "Change" " . " : " . $row["SubjectCCScore"] . " } "
. "</td>";
echo "<br>";
echo "]";
echo "</tr>";
}
// close table>
echo "</table>";
?>
</body>
</html>
答案 0 :(得分:0)
您需要做的就是将数组放在json_encode()
所以这样:
$array = array('first_value', 'second_value');
echo json_encode($array);
PHP会将数组作为JSON返回。
如果您想要解码它,就像它一样简单。使用json_decode()
instaed。
echo json_decode($json_array);