[英]How to export data from user modx database to form?
我已經在modx數據庫中創建了表(訂單),並且我需要將數據從該數據庫導出到站點中的表。 我跟隨以下片段進入數據庫
<?php
function agregarCargas( &$fields )
{
global $modx;
// Init our array
$dbTable = array();
$dbTable['subject'] = $modx->db->escape($fields['subject']);
$dbTable['fullname'] = $modx->db->escape($fields['fullname']);
$dbTable['message'] = $modx->db->escape($fields['message']);
// Run the db insert query
$dbQuery = $modx->db->insert($dbTable, 'orders' );
return true;
}
?>
如何從數據庫導出? 片段還是? 謝謝。
(舊線程,僅供嘗試解決此問題的新手...)
看一下您正在使用的API,我猜您仍然受制於舊的MODx版本。 (演化)
您應該看一下MODX Evolution的API :: DB文檔
以下內容將填充您的HTML表:
$res = $modx->db->select("subject, fullname", 'orders');
$res_rows = $modx->db->makeArray($res);
$rows = "";
for($n=0;$n<count($res_rows);$n++){
$rows .= "<tr><td>".$res_rows['subject']."</td><td>".$res_rows['fullname']."</td></tr>\n";
}
return $rows;
(當然,您應該使用塊而不是硬編碼的HTML)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.