
03-03-2007, 13:52
|
|
|
|
חבר מתאריך: 21.02.07
הודעות: 26
|
|
|
עזרה בשילוב SQL עם SMARTY
שלום אני רוצה ליישם שאילתת SQL ע"י תבנית סמרטי
רשמתי את הקוד הבא :
<?php
require('c:/smarty/libs/Smarty.class.php');
require_once "dbconn.inc.php";
$smarty2->template_dir = 'c:/wamp/www/smarty/templates';
$smarty2->config_dir = ' c:/wamp/www/smarty/config';
$smarty2->cache_dir = 'c:/smarty/smarty_cache';
$smarty2->compile_dir = 'c:/smarty/templates_c';
$smarty2 = new Smarty;
require_once "dbconn.inc.php";
// hebrow with mysql
mysql_query("SET NAMES 'hebrew'");
$sql = "SELECT * FROM middle_stories";
$smarty2->assign('reports', $db->getAll($sql));
$smarty2->display('midtable.tpl');
?>
והתבנית midtable.tpl היא :
{includefile="header.tpl" title="Table"}
<table>
{sectionname=coloop=$reports}
<tr>
<td>{$reports[co].title}</td>
</tr>
<tr><td>{$reports[co].text}</td>
</tr>
{sectionelse}
<tr><tdcolspan="5">Noitemsfound</td></tr>
{/section}
</table>
{includefile="footer.tpl"}
אני מקבל שגיאה
Fatal error: Call to a member function getAll() on a non-object in C:\wamp\www\4.php on line 14
למישהו יש כיוון ?
נערך לאחרונה ע"י uriwald בתאריך 03-03-2007 בשעה 13:55.
|