Smarty實現輸出數據庫一張表的所有信息(如用戶表)

<test2.php>

require_once "conn.php";

require_once "smarty_reg.php";

$sql="select * from jinyifang_user_admin";

$result=mysql_query($sql);

//將用戶表的信息賦給$arr[]數組中

while($rows=mysql_fetch_array($result)){
$arr[]=array('id'=>$rows[0],'user_name'=>$rows[1],'user_pwd'=>$rows[2]);
}


$smarty->assign('per',$arr);

$smarty->display('test2.tpl');


<test2.tpl>

<{section name=customer loop=$per}>
<{$per[customer].id}>   <{$per[customer].user_name}>    <{$per[customer].user_pwd}><br/>
<{/section}>


<hr/>




發佈了32 篇原創文章 · 獲贊 6 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章