|
|
|
สอบถามการใช้ While ทําข้อมูล Json ตามรูปแบบนี้ครับ |
|
|
|
|
|
|
|
ผมต้องการวนลูปโดย fetch จากฐานข้อมูลแล้ว ทําข้อมูลให้อยู่ในรูป Json ประมาณนีครับ
Code (PHP)
[
{"title": "simple node (no explicit id, so a default key is generated)" },
{"key": "2", "title": "item1 with key and tooltip", "tooltip": "Look, a tool tip!" },
{"key": "3", "title": "<span>item2 with <b>html</b> inside a span tag</span>" },
{"key": "4", "title": "node 4" },
{"key": "5", "title": "using href", "href": "http://www.wwWendt.de/" },
{"key": "6", "title": "node with some extra classes (will be added to the generated markup)", "extraClasses": "my-extra-class" },
{"key": "10", "title": "Folder 1", "folder": true, "children": [
{"key": "10_1", "title": "Sub-item 1.1", "children": [
{"key": "10_1_1", "title": "Sub-item 1.1.1"},
{"key": "10_1_2", "title": "Sub-item 1.1.2"}
]},
{"key": "10_2", "title": "Sub-item 1.2", "children": [
{"key": "10_2_1", "title": "Sub-item 1.2.1"},
{"key": "10_2_2", "title": "Sub-item 1.2.2"}
]}
]},
{"key": "20", "title": "Simple node with active children (expand)", "expanded": true, "children": [
{"key": "20_1", "title": "Sub-item 2.1", "children": [
{"key": "20_1_1", "title": "Sub-item 2.1.1", "children": [
{"key": "20_1_1_1", "title": "Sub-item 2.1.1.1"}
]},
{"key": "20_1_2", "title": "Sub-item 2.1.2"}
]},
{"key": "20_2", "title": "Sub-item 2.2", "children": [
{"key": "20_2_1", "title": "Sub-item 2.2.1"},
{"key": "20_2_2", "title": "Sub-item 2.2.2"}
]}
]},
Tag : PHP
|
|
|
|
|
|
Date :
2014-12-11 12:01:30 |
By :
kenghockey |
View :
745 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้ json_encode เลยไม่ได้หรอครับ
Code (PHP)
$json = array();
$mysql = mysql_query("select * from tb_name");
while($rs = mysql_fetch_array($mysql)){
//$json[] = $rs;
array_push($json,$rs);
}
echo json_encode($json);
|
|
|
|
|
Date :
2014-12-11 14:02:51 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่ได้ครับต้องทําตาม Format อย่างเดียว ตัวนี้มาจาก plugin menu
|
|
|
|
|
Date :
2014-12-11 15:41:28 |
By :
kenghockey |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|