Hello! help to understand: There is a table in the database:
id f_gdpec w_gdpec url_gdpec p_gdspec 1 Москва Красноярск www.test.ru 450 2 Москва Красноярск www.test.ru 900 3 Москва Красноярск www.test.ru 600
It is necessary to pull data from the database using php and display it using smarty tools. that's what i did: 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_tags.tpl'); return true; } ?>
template:
{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}
I can not understand what is wrong. errors would be displayed, maybe I could dig. The module does not see the template and accordingly the data is not transferred to the template I ask for your help.