我在joomla中創建自定義組件,它將數據保存在如下這樣的數據庫中: [「2013-05-04」,「2013-05-05」,「2013-05 -06" , 「2013年5月7日」, 「2013年5月8日」, 「2013年5月9日」, 「2013年5月10日」, 「2013年5月11日」,「2013年5月12日「]從Joomla組件中的數據庫獲取列表數據
有什麼辦法讓我可以在模塊上很好地獲取這些數據?
謝謝。
我在joomla中創建自定義組件,它將數據保存在如下這樣的數據庫中: [「2013-05-04」,「2013-05-05」,「2013-05 -06" , 「2013年5月7日」, 「2013年5月8日」, 「2013年5月9日」, 「2013年5月10日」, 「2013年5月11日」,「2013年5月12日「]從Joomla組件中的數據庫獲取列表數據
有什麼辦法讓我可以在模塊上很好地獲取這些數據?
謝謝。
,如果我得到你的問題,你想顯示這些出放在你module.See下面的例子:
<?php
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
$output = json_decode($json , true);
print_r($output);
?>
輸出:
Array
(
[a] => 1
[b] => 2
[c] => 3
[d] => 4
[e] => 5
)
然後你可以如下使用這樣的輸出:
<?php
foreach ($output as $value){
echo $value;
}
?>
欲瞭解更多信息檢查此:http://php.net/manual/en/function.json-decode.php 希望這^ h幫助你。
它通過json_decode()函數完成。
它是單個記錄嗎? – Toretto 2013-03-05 11:32:17
嗨toretto,我已經通過json_decode() – user1451145 2013-03-05 11:33:56
所以它解碼後,你有一個數組?不是嗎? – Toretto 2013-03-05 11:36:35