<?
$read_num="5";
$mem_account=$_REQUEST["mem_account"];
$link=mysql_connect("localhost","root","111111");
mysql_select_db("robin_data",$link);
$str="select count(*) from myitem";
$list =mysql_query($str,$link);
list($disscuss_count) = mysql_fetch_row($list);
$str="select * from myitem ";
$list =mysql_query($str,$link);
?>
<table><tr>
<td colspan="2" bgcolor="#3366CC"><span style="color: #FFFFFF; font-size: 14px;">
請選擇商品頁數<font face="Arial Black"> |
<?
//抓取頁數
$all_page=ceil($disscuss_count/$read_num);
for($i=1;$i<=$all_page;$i++){
echo "<a href='product.php?page_num=$i'> $i </a>|";
}
echo "<a href='product.php?page_num=0'> 全部商品 </a>|";
?>
</font></strong></td>
<td bgcolor="#3366CC"><span style="color: #FFFFFF; font-size: 14px;"><font face="Arial Black">目前第<? echo $page_num ?>頁</font></strong></td>
</tr><tr>
<td width="177" align="center" bgcolor="#3366CC"><div align="center"><span style="color: #FFFFFF; font-size: 18px;"><strong>商品照片</strong></span></div></td>
<td width="454" align="center" bgcolor="#3366CC"><div align="center"><span style="color: #FFFFFF; font-size: 18px;"><strong>商品介紹</strong></span></div></td>
<td width="141" align="center" bgcolor="#3366CC"><div align="center"><span style="color: #FFFFFF; font-size: 18px;"><strong>訂購</strong></span></div></td>
</tr>
<?
//分頁分析
if(empty($page_num))$page_num="1";
$start_num=$read_num*($page_num-1);
if($page_num=0){
$str="select * from myitem limit $start_num,$read_num";
}
else{
$str="select * from myitem ";
}
$list =mysql_query($str,$link);
while(list($item_id,$item_no,$item_name,$item_price,$item_date,$item_co,$item_tel,$item_man,$item_number,$item_memo,$com_date,$fupload,$item_group) = mysql_fetch_row($list)){
echo "<tr><td align='center' ><a href='homeitem.php?item_id=".$item_id."&item_group=".$item_group."'><img src='image/".$fupload."' width='110' height='90' border='0'></a></td><td>".$item_name."<br>".$item_memo."</td><td align='center'><a href='orderitem.php?item_id=".$item_id."&mem_account=".$mem_account."'><img src='image/car.jpg' width='42' height='38' border='0' alt='我要買".$item_name."' ></a></td></tr>";
}
mysql_close($link);
?>
</table>
>即時新聞-熱門
2008年3月29日星期六
php分頁設計
订阅:
博文评论 (Atom)
0 评论:
发表评论