补充资料
以下是主要部分代码,帮帮我还可以怎么写才最优化? ///////$recordcount定义每一页所要显示的记录数////////////////
$pagerecords=10;
////////读取page当前页号/////////////////////////
$page=$_GET["page"];
if($page=="")
{
$page=1;
}
///////计算当前页号所对应的记录的开始处$start/////////
$start=$pagerecords*($page-1);
///////编写查询当前页号的记录///////////////////////////
$select_sprod = "select PSPID,PUID,PID,Pname,Pno,Para,Price,Photo,Pstock,";
$select_sprod .= "Pfact,Pack,Plotno,Pspeci from products where ";
$select_sprod .= "PSPID in (select SPID from sproducts where SGPID =$GPID) order by Pdate desc limit $start,$pagerecords";
//echo $select_sprod;
////////编写获取总记录数的SQL语句//////////////////////
$selectCount="select count(*) from products where PSPID in (select SPID from sproducts where SGPID =$GPID) order by Pdate desc ";
$result_sprod = mysql_query($select_sprod);
$resultCount=mysql_query($selectCount);
list($totalrecords)=mysql_fetch_row($resultCount);
while($arr_sprod = mysql_fetch_array($result_sprod))
{
$select_user = "select Utruename,Ucompany,Utel,Uemail from users where UID='$arr_sprod[PUID]'";
$result = mysql_query($select_user);
$arr_str = mysql_fetch_array($result);
以下是主要部分代码,帮帮我还可以怎么写才最优化? ///////$recordcount定义每一页所要显示的记录数////////////////
$pagerecords=10;
////////读取page当前页号/////////////////////////
$page=$_GET["page"];
if($page=="")
{
$page=1;
}
///////计算当前页号所对应的记录的开始处$start/////////
$start=$pagerecords*($page-1);
///////编写查询当前页号的记录///////////////////////////
$select_sprod = "select PSPID,PUID,PID,Pname,Pno,Para,Price,Photo,Pstock,";
$select_sprod .= "Pfact,Pack,Plotno,Pspeci from products where ";
$select_sprod .= "PSPID in (select SPID from sproducts where SGPID =$GPID) order by Pdate desc limit $start,$pagerecords";
//echo $select_sprod;
////////编写获取总记录数的SQL语句//////////////////////
$selectCount="select count(*) from products where PSPID in (select SPID from sproducts where SGPID =$GPID) order by Pdate desc ";
$result_sprod = mysql_query($select_sprod);
$resultCount=mysql_query($selectCount);
list($totalrecords)=mysql_fetch_row($resultCount);
while($arr_sprod = mysql_fetch_array($result_sprod))
{
$select_user = "select Utruename,Ucompany,Utel,Uemail from users where UID='$arr_sprod[PUID]'";
$result = mysql_query($select_user);
$arr_str = mysql_fetch_array($result);
2 做联合查询后,再过滤.
3 做好查询数据的cache.