问题如下,我用PHP+smarty做了个分页,分页正常显示了,但是内容列表却显示不了,对smarty不甚了解,还请大家指导,我把代码贴出来
<?php
/*
* Created on 2008-4-7
*
* To change the template for this generated file go to
* Window - Preferences - PHPeclipse - PHP - Code Templates
*/
include_once("../smarty/temp/Smarty.class.php"); //包含smarty类文件
define("NUM",8 ); //定义每次显示的新闻条数
require('../include/mysql.php');
$smarty = new Smarty(); //建立smarty实例对象$smarty
$smarty->templates_dir = "../smarty/china/"; //设置模板目录
$smarty->compile_dir = "../smarty/templates_c"; //设置编译目录
$smarty->cache_dir = "../smarty/cache"; //设置缓存目录
$smarty->cache_lifetime = 60 * 60 * 24; //设置缓存时间
$smarty->caching = false; //这里是调试时设为false,发布时请使用true
$smarty->left_delimiter = "<{"; //设置左边界符
$smarty->right_delimiter = "}>"; //设置右边界符
$db = mysql_connect("$db_server", "$db_username", "$db_password") or die("数据库连接错误!");
mysql_select_db("$db_name", $db);
mb_internal_encoding("UTF-8");
//silk line list
//$smarty->caching = false;
$lady_url ="http://192.168.0.141/china/silk.php";
$content = array();
$pagesize = 1;
$strQuery= "SELECT id,line_name,line_upload,line_intro,line_vprice from line_lines where line_show=0 order by id desc";
$result = mysql_query($strQuery);
//结果集
$total = mysql_num_rows($result);
//记录条数
$totalpage = ceil($total/$pagesize);
//总页数
$page = ceil($_GET["pos"])+1;
//当前页
$strQuery= "limit ".($pagesize * ($page-1)).", ".$pagesize;
//语句
$idx = 0;
$result = mysql_query($strQuery);
while ($row = @mysql_fetch_array($result))
{
$array[] = array("id"=>$row["id"],
"name"=>$row["line_name"],
"price"=> $row["line_vprice"],
'image'=>$row['line_upload'],
'intro'=>$row['line_intro'],
);
}
$smarty->assign("line_list", $array);
unset($array);
$smarty->assign('totalpage',$totalpage);
$smarty->assign('lady_url',$lady_url);
$smarty->display("silk.tpl",$page);
mysql_close($db);
$smarty->display("../../smarty/china/silk.tpl");
?>
tpl:
<{section name=loop loop=$line_list}>
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="shtour2">
<tr>
<td width="82%" height="20" class="shtour2"><h3><{$line_list[loop].name}></h3></td>
<td width="18%" align="center" class="STYLE5">$<{$line_list[loop].price}></td>
</tr>
<tr>
<td colspan="2"><table width="590" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="490" height="50" align="left" class="shtour2"><{$line_list[loop].intro}></td>
<td width="100" rowspan="2" align="center"><img src="../<{$line_list[loop].image}>" width="90" height="60" border="1"></td>
</tr>
<tr>
<td height="20" align="left" class="shtour2">Detail</td>
</tr>
</table></td>
</tr>
</table>
<{sectionelse}>
对不起,没有任何新闻输入!
<{/section}>
<br>
<{pager rowcount=$totalpage limit=1 shift=1 no_first=true separator="|" class_text="pager_text" txt_pos="side"}>
<p> </p></td>
</tr>
</table>