[請益] {Smarty問題}撈出資料怎麼顯示不出來呢?

看板PHP作者 (我的生命因你而發光)時間16年前 (2009/03/01 20:19), 編輯推噓1(103)
留言4則, 3人參與, 最新討論串1/3 (看更多)
目前我有個資料表有三個欄位 ID - 主鍵編號 Name - 姓名 Tel - 手機號碼 我的目的只是想把資料庫中的所有資料作顯示 首先一些設定檔放在main.php <?php include "library/Smarty/Smarty.class.php"; define('APP_PATH', str_replace('\\', '/', dirname(__FILE__))); $tpl = new Smarty(); $tpl->template_dir = APP_PATH . "/templates/"; $tpl->compile_dir = APP_PATH . "/templates_c/"; $tpl->config_dir = APP_PATH . "/configs/"; $tpl->cache_dir = APP_PATH . "/cache/"; ?> 執行的test.php <?php require_once('Connections/test_conn.php'); ?> <?php mysql_select_db($database_test_conn, $test_conn); $query_Recordset1 = "SELECT * FROM test ORDER BY ID ASC"; $Recordset1 = mysql_query($query_Recordset1, $test_conn) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); require "main.php"; $tpl->assign('$AllMan', $Recordset1); $tpl->display('test2.htm'); mysql_free_result($Recordset1); ?> 顯示的樣板test.htm <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=big5"> <title>姓名列表</title> </head> <body> {section name="sel1" loop=$AllMan} <table width="300" border="1"> <tr> <td>{$AllMan[sel1].ID}</td> <td>{$AllMan[sel1].Name}</td> <td>{$AllMan[sel1].Tel}</td> </tr> </table> {/section} </body> </html> 我如果單純在同一支php裡面做顯示都沒有問題 這樣應該等於說撈出來的資料應該沒錯才對 指示分開成樣板和php時候就都一片空白 不知道哪邊的問題呢? 謝謝~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.193.225.140

03/01 20:46, , 1F
$tpl->assign('AllMan', $Recordset1); 應改成這樣?
03/01 20:46, 1F

03/02 05:47, , 2F
改了之後,看撈出來的東西都空白,資料庫檔案有三筆
03/02 05:47, 2F

03/02 05:48, , 3F
但看樣板中的迴圈卻跑了四筆,都為沒有資料!
03/02 05:48, 3F

09/15 00:44, , 4F
要不要轉CodeJob?
09/15 00:44, 4F
文章代碼(AID): #19gdrbvU (PHP)
文章代碼(AID): #19gdrbvU (PHP)