PHP数据库输出与模板的配合使用
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
程序文件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 编辑过 |
关键字查询
相关文章
正在查询... |