Teraz chcę wyświetlić dane z tej tablicy w smarty.
<?php function wyswietl() { $sql = 'SELECT * FROM tabela '; $result = $this->db->query($sql); while($row = $this->db->fetch($result,$type)) { $this->data[] = $row; } return $this->data; } $array = wyswietl(); $template->assign('dane', $array); $template->display('tresc.tpl'); ?>
Kod
{section name=i loop=$dane}
{$smarty.section.i.iteration}
{$dane[i].imie}
{$dane[i].nazwisko}
{$dane[i].glosy}
{/section}
{$smarty.section.i.iteration}
{$dane[i].imie}
{$dane[i].nazwisko}
{$dane[i].glosy}
{/section}
problem polega na tym, że jeśli dane w bazie zawierają cudzysłowa, apostrofy to wyświetla je ze slashem. Dlatego trzeba zastosować funkcję stripslashes().
Ale gdzie mam to zrobić?
Nie chciałbym, aby stripslashes był już zastosowany w tablicy, jak to jest pokazane w manualu
Smarty jakoś sobię z tym radzi?