帮助我理解:数据库中有一个表:
id f_gdpec w_gdpec url_gdpec p_gdspec
1 Москва Красноярск www.test.ru 450
2 Москва Красноярск www.test.ru 900
3 Москва Красноярск www.test.ru 600
需要从数据库中提取数据并显示意味着 php 意味着 smarty。这就是我所做的:module.php:
<?php
function mod_gdspec($module_id){
$inCore = cmsCore::getInstance();
$inDB = cmsDatabase::getInstance();
$cfg = $inCore->loadModuleConfig($module_id);
$sql = "SELECT f_gdpec,
w_gdpec,
url_gdpec,
p_gdspec
FROM cms_gdspec";
$result = $inDB->query($sql) ;
if ($inDB->num_rows($result)){
$items = array();
while ($item=$inDB->fetch_assoc($result)){
$items[]=$item;
}
}
$smarty = $inCore->initSmarty('modules', 'mod_gdspec.tpl');
$smarty->assign('items', $items);
$smarty->display('mod_gdspec.tpl');
return true;
}
?>
模板 mod_gdspec.tpl:
{foreach item=item from=$items}
<div class="mod_latest_entry">
<div class="mod_latest_f_gdpec">
{$item.f_gdpec}
</div>
<div class="mod_latest_w_gdpec" >
{$item.w_gdpec}
</div>
</div>
{/foreach}
来自 tabditsy 的数据没有出现,我无法理解有多少。问你的能力。感谢您的关注。
更正的脚本 - module.php!!!!!!!!!!!!!