【发布时间】:2018-06-25 04:55:16
【问题描述】:
我的 DB>test (Table) 中有 JSON 格式的数据
[{
"day": 0,
"periods": []
}, {
"day": 1,
"periods": [{
"start": "01:45",
"end": "07:45",
"title": ""
}]
}, {
"day": 2,
"periods": [{
"start": "02:45",
"end": "07:45",
"title": ""
}]
}, {
"day": 3,
"periods": [{
"start": "01:45",
"end": "07:15",
"title": ""
}]
}, {
"day": 4,
"periods": [{
"start": "04:45",
"end": "09:45",
"title": ""
}]
}, {
"day": 5,
"periods": []
}, {
"day": 6,
"periods": []
}]
我想在 Jquery 调度程序中获取它,如下所示:
<script>
$(function () {
$("#schedule3").jqs({
});
</script>
我的问题是我无法获取 mySQL 数据库中保存的 json 值并将其显示在 jQuery 调度程序上。image 下面是我的 import.php 代码:
$selected = mysqli_select_db($conn,"db")
$fetch_port_relation = "SELECT * FROM `test`";
$result_port_relation = $conn->query($fetch_port_relation);
if ($result_port_relation->num_rows > 0) {
// output data of each row
while($ios_row = $result_port_relation->fetch_assoc()) {
$data = $ios_row['test'];
$jsondata = json_decode($data);
$jsondata->day; //this returns
print_r($data);
foreach($jsondata->periods as $periods) {
echo $periods->start;
【问题讨论】:
-
你的问题到底是什么?
-
你需要解释更多。你有什么问题,你尝试了什么,你在哪里卡住了?
-
嗨,Alex,我被困在从 mySQL 获取 json 数据(我能够获取它但无法解码)并在 jQuery 每周调度程序脚本的前端获取它。跨度>