PHP數(shù)據(jù)庫輸出與模板的配合使用
當(dāng)前位置:點(diǎn)晴教程→知識管理交流
→『 技術(shù)文檔交流 』
程序文件getsql.php: <?PHP $db = mysql_connect('localhost',$cs_dbuser,$cs_dbpassword) or die("Database error"); mysql_select_db($cs_dbname, $db); //SOLUTION:: add this comment before your 1st query -- force multiLanuage support mysql_query("set names 'GB2312'"); $query = "select * from userinf"; $result = mysql_query($query); $entries = array(); while ($row = mysql_fetch_object($result)) { $entries[]=$row; } include('show.tpl'); mysql_free_result($result); ?> 模板文件show.tpl: <?php foreach($entries as $entry):?>
<div class="mid-class"> <div class="mid-class-con"> <dl><dt>工號:<?=$entry->ID?>、<?=$entry->name?></dt><dd>姓名:<?=$entry->username ?></dd><dd class="g"><?=$entry->userdept?></dd><dd class="mid-dd"></dd></dl> </div> </div> <?php endforeach;?> 該文章在 2012/7/11 17:13:57 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |