$sql = "SELECT db_image.product_id,db_proconter.pro_conect,db_proconter.pro_description,db_image.description FROM db_image, db_proconter where db_image.product_id = db_proconter.id order by db_image.product_id desc limit $firstcount,$displaypg";
$firstcount,$displaypg  这两个变量获取不到值?<?php  
include("init.php");
include("title.php");
include("db_mysql.php");$smarty -> assign('listnews',productlist());
$smarty -> assign('a',$a);//$smarty -> assign('pageSmarty',$pagesmarty);
$smarty -> display('news.htm');/*** 分页 显示***/
function _PAGEFT($totle, $displaypg = 10, $url = '') { global $page, $firstcount, $pagenav, $_SERVER; $GLOBALS["displaypg"] = $displaypg; if (!$page)
$page = 1;
if (!$url) {
$url = $_SERVER["REQUEST_URI"];
} //URL分析:
$parse_url = parse_url($url);
$url_query = $parse_url["query"]; //单独取出URL的查询字串
if ($url_query) {
$url_query = ereg_replace("(^|&)page=$page", "", $url_query);
$url = str_replace($parse_url["query"], $url_query, $url);
if ($url_query)
$url .= "&page";
else
$url .= "page";
} else {
$url .= "?page";
}
$lastpg = ceil($totle / $displaypg); //最后页,也是总页数
$page = min($lastpg, $page);
$prepg = $page -1; //上一页
$nextpg = ($page == $lastpg ? 0 : $page +1); //下一页
$firstcount = ($page -1) * $displaypg; //开始分页导航条代码:
$pagenav = "显示第 <B>" . ($totle ? ($firstcount +1) : 0) . "</B>-<B>" . min($firstcount + $displaypg, $totle) . "</B> 条记录,共 $totle 条记录"; //如果只有一页则跳出函数:
if ($lastpg <= 1)
return false; $pagenav .= " <a href='$url=1'>首页</a> ";
if ($prepg)
$pagenav .= " <a href='$url=$prepg'>前页</a> ";
else
$pagenav .= " 前页 ";
if ($nextpg)
$pagenav .= " <a href='$url=$nextpg'>后页</a> ";
else
$pagenav .= " 后页 ";
$pagenav .= " <a href='$url=$lastpg'>尾页</a> "; //下拉跳转列表,循环列出所有页码:
$pagenav .= " 到第 <select name='topage' size='1' onchange='window.location=\"$url=\"+this.value'>\n";
for ($i = 1; $i <= $lastpg; $i++) {
if ($i == $page)
$pagenav .= "<option value='$i' selected>$i</option>\n";
else
$pagenav .= "<option value='$i'>$i</option>\n";
}
$pagenav .= "</select> 页,共 $lastpg 页";
}



function productlist(){ 
$numq =mysql_query("SELECT db_image.product_id,db_proconter.pro_conect,db_proconter.pro_description,db_image.description FROM eaglestar.db_image, eaglestar.db_proconter where db_image.product_id = db_proconter.id");
 
$num = mysql_num_rows($numq); //总共多少页
 _PAGEFT($total,2);
echo $pagenav;
    $sql = "SELECT db_image.product_id,db_proconter.pro_conect,db_proconter.pro_description,db_image.description FROM db_image, db_proconter where db_image.product_id = db_proconter.id order by db_image.product_id desc limit $firstcount,$displaypg";
echo $sql;
$rs = mysql_query($sql);
$arr = array();
while($row = mysql_fetch_array($rs)){
$arr[$row['product_id']] ['product_id'] = $row['product_id'];
$arr[$row['product_id']] ['description'] = $row['description'];
$arr[$row['product_id']] ['pro_description'] = mb_substr($row['pro_description'],1,60,'UTF-8');
//$a =  $arr[$row['product_id']] ['pro_conect']; 
         //echo  substr($a,100,50);             
} return $arr;
 }

?>

解决方案 »

  1.   

    提示错误信息:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in D:\AppServ\www\eaglestar\news.php on line 87
      

  2.   

    你这个应该是数据库里搜不到值,你进行while循环之前,先判断一下
    <?php
    if(!$rs){
    exit ("数据库里没有值");
    }
    ?>
      

  3.   

    当点击下一页的时候,重新加载页面,$firstcount,$displaypg被重置。
    应该把赋值后的$firstcount,$displaypg放到hidden中,点击下一页,通过获取hidden的值,来取得$firstcount,$displaypg。
      

  4.   

    mysql_fetch_array()的参数好像不对,你查看一下这个函数,应该有两个参数吧