|
|
|
ช่วยด้วยค่ะ (การแบ่งหน้า) หนูงมมา 6 วันแล้วมันไม่ได้ซักทีค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<?
$id_type=$_GET[id_type];
$id_sub_type=$_GET[id_sub_type];
$id_sub_type2=$_GET[id_sub_type2];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
<title>S.P.E. GROUP</title>
<link href="style_do.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrap">
<div id="header">
<div id="nav"><form action="#">
<div id="search"><input type="text" class="keyword" value="Search" />
</div>
</form>
<div id="topPanel">
<? include "top_menu.php"; ?>
</div>
</div>
<div class="clear"></div>
<?
include "connect.php";
$sql_name_type= "select name_type from type where id_type = $id_type";
$result_name_type=mysql_db_query($dbname,$sql_name_type);
while ($rs = mysql_fetch_array($result_name_type)) {
$name_type=$rs[name_type];
}
?>
<?
$sql_name_sub_type= "select name_sub_type from sub_type where id_sub_type = $id_sub_type and id_type = $id_type";
$result_name_sub_type=mysql_db_query($dbname,$sql_name_sub_type);
while ($rs = mysql_fetch_array($result_name_sub_type)) {
$name_sub_type=$rs[name_sub_type];
}
?>
<?
$sql_name_sub_type2= "select name_sub_type2 from sub_type2 where id_sub_type = $id_sub_type and id_type = $id_type and id_sub_type2=$id_sub_type2";
$result_name_sub_type2=mysql_db_query($dbname,$sql_name_sub_type2);
while ($rs = mysql_fetch_array($result_name_sub_type2)) {
$name_sub_type2=$rs[name_sub_type2];
}
?>
</div>
<div id="content">
<div id="breadcrumb"><a href="product.php">product</a> » <a href="#" ><?=$name_type?></a> » <a href="type_step3.php?id_type=<?=$id_type?>&id_sub_type1=<?=$id_sub_type?>&id_sub_type2=<?=$id_sub_type2?>"><?=$name_sub_type?></a> » <a href="type_step3-2.php?id_type=<?=$id_type?>&id_sub_type=<?=$id_sub_type?>&id_sub_type2=<?=$id_sub_type2?>" class="active" ><?=$name_sub_type2?></a></div>
<div id="right1">
<div class="img_head">
<?
$sql3= "select photo_detail_sub_type2 from sub_type2 where id_sub_type = $id_sub_type and id_type = $id_type and id_sub_type2=$id_sub_type2";
$result3=mysql_db_query($dbname,$sql3);
while ($rs = mysql_fetch_array($result3)) {
$photo_detail_sub_type2 =$rs[photo_detail_sub_type2 ];
$detail_sub_type_for_type=$rs[detail_sub_type_for_type];
echo "<img src = 'photo/photo_sub_type2/$photo_detail_sub_type2 ' width='700' height='200' align='center' border='1px'>";
}
?>
</div>
<h2 class="sec_head">Product List</h2>
<div id="catalogue">
<?
$sql_product_all="select id_product from product where id_type ='$id_type' and id_sub_type = '$id_sub_type' and id_sub_type2='$id_sub_type2' ";
$result_product_all=mysql_db_query($dbname,$sql_product_all);
$num_product=mysql_num_rows($result_product_all);
//while ($rs = mysql_fetch_array($result_product_all)) {
//$id_product_all[]=$rs[id_product];
//}
$sql_brand_all="select distinct id_brand from product where id_type ='$id_type' and id_sub_type = '$id_sub_type' and id_sub_type2='$id_sub_type2' ";
$result_brand_all=mysql_db_query($dbname,$sql_brand_all);
while ($rs = mysql_fetch_array($result_brand_all)) {
$id_brand_all[]=$rs[id_brand];
}
for($i=0;$i< count($id_brand_all);$i++)
{
$brand1="select id_brand,menu_brand from brand where id_brand = $id_brand_all[$i]";
$result_brand1=mysql_db_query($dbname,$brand1);
while ($rs = mysql_fetch_array($result_brand1)) {
$id_brand1[]=$rs[id_brand];
$menu_brand1[]=$rs[menu_brand];
}
$num_brand="select id_product from product where id_type = $id_type and id_brand = $id_brand_all[$i] and id_sub_type = $id_sub_type and id_sub_type2 = $id_sub_type2";
$result_num_brand=mysql_db_query($dbname,$num_brand);
$num=mysql_num_rows($result_num_brand);
while ($rs = mysql_fetch_array($result_num_brand)) {
$id_product111[]=$rs[id_product];
}
echo "<strong>ALL ($num_product) </strong><a href = 'select_brand2.php?id_brand=$id_brand1[$i]&id_type=$id_type&id_sub_type=$id_sub_type&id_sub_type2=$id_sub_type2'><img src = 'photo/menu_brand/$menu_brand1[$i] ' height='17' width='67' border='0px'><strong>($num)</strong></a> ";
}
?>
<?php
$link=mysql_connect("localhost","root","nakedkung");
mysql_select_db("scpe3");
mysql_query("SET NAMES TIS620");
?>
<?php
// สร้างฟังก์ชั่น สำหรับแสดงการแบ่งหน้า
function page_navigator($before_p,$plus_p,$total,$total_p,$chk_page){
global $urlquery_str;
$pPrev=$chk_page-1;
$pPrev=($pPrev>=0)?$pPrev:0;
$pNext=$chk_page+1;
$pNext=($pNext>=$total_p)?$total_p-1:$pNext;
$lt_page=$total_p-4;
if($chk_page>=0){
echo "<a href='?s_page=$pPrev&id_type=$_GET[id_type]&id_sub_type=$_GET[id_sub_type]&id_sub_type2=$_GET[id_sub_type2]&urlquery_str=".$urlquery_str."' class='naviPN'>Prev</a>";
}
if($total_p>=11){
if($chk_page>=4){
echo "<a $nClass href='?s_page=0&id_type=$_GET[id_type]&id_sub_type=$_GET[id_sub_type]&id_sub_type2=$_GET[id_sub_type2]&urlquery_str=".$urlquery_str."'>1</a><a class='SpaceC'>. . .</a>";
}
if($chk_page<4){
for($i=0;$i<$total_p;$i++){
$nClass=($chk_page==$i)?"class='selectPage'":"";
if($i<=4){
echo "<a $nClass href='?s_page=$i&id_type=$_GET[id_type]&id_sub_type=$_GET[id_sub_type]&id_sub_type2=$_GET[id_sub_type2]&urlquery_str=".$urlquery_str."'>".intval($i+1)."</a> ";
}
if($i==$total_p-1 ){
echo "<a class='SpaceC'>. . .</a><a $nClass href='?s_page=$i&id_type=$_GET[id_type]&id_sub_type=$_GET[id_sub_type]&id_sub_type2=$_GET[id_sub_type2]&urlquery_str=".$urlquery_str."'>".intval($i+1)."</a> ";
}
}
}
if($chk_page>=4 && $chk_page<$lt_page){
$st_page=$chk_page-3;
for($i=1;$i<=5;$i++){
$nClass=($chk_page==($st_page+$i))?"class='selectPage'":"";
echo "<a $nClass href='?s_page=".intval($st_page+$i).$_SESSION['ses_qCurProvince']."'>".intval($st_page+$i+1)."</a> ";
}
for($i=0;$i<$total_p;$i++){
if($i==$total_p-1 ){
$nClass=($chk_page==$i)?"class='selectPage'":"";
echo "<a class='SpaceC'>. . .</a><a $nClass href='?s_page=$i&id_type=$_GET[id_type]&id_sub_type=$_GET[id_sub_type]&id_sub_type2=$_GET[id_sub_type2]&urlquery_str=".$urlquery_str."'>".intval($i+1)."</a> ";
}
}
}
if($chk_page>=$lt_page){
for($i=0;$i<=4;$i++){
$nClass=($chk_page==($lt_page+$i-1))?"class='selectPage'":"";
echo "<a $nClass href='?s_page=".intval($lt_page+$i-1).$_SESSION['ses_qCurProvince']."'>".intval($lt_page+$i)."</a> ";
}
}
}else{
for($i=0;$i<$total_p;$i++){
$nClass=($chk_page==$i)?"class='selectPage'":"";
echo "<a href='?s_page=$i&id_type=$_GET[id_type]&id_sub_type=$_GET[id_sub_type]&id_sub_type2=$_GET[id_sub_type2]&urlquery_str=".$urlquery_str."' $nClass >".intval($i+1)."</a> ";
$_REQUEST['id_type'];
}
}
if($chk_page<=$total_p-1){
echo "<a href='?s_page=$pNext&id_type=$_GET[id_type]&id_sub_type=$_GET[id_sub_type]&id_sub_type2=$_GET[id_sub_type2]&urlquery_str=".$urlquery_str."' class='naviPN'>Next</a>";
}
}
?>
<?php
$q="select * from product where id_type='$id_type' and id_sub_type='$id_sub_type' and id_sub_type2='$id_sub_type2'";
$q.=" ORDER BY id_product ";
$qr=mysql_query($q);
$total=mysql_num_rows($qr);
$e_page=20; // กำหนด จำนวนรายการที่แสดงในแต่ละหน้า
if(!isset($s_page)){
$s_page=0;
}else{
$chk_page=$s_page;
$s_page=$s_page*$e_page;
}
$q.=" LIMIT $s_page,$e_page";
$qr=mysql_query($q);
if(mysql_num_rows($qr)>=1){
$plus_p=($chk_page*$e_page)+mysql_num_rows($qr);
}else{
$plus_p=($chk_page*$e_page);
}
$total_p=ceil($total/$e_page);
$before_p=($chk_page*$e_page)+1;
?>
<?php if($total>0){ ?>
<div class="browse_page">
<?php
// เรียกใช้งานฟังก์ชั่น สำหรับแสดงการแบ่งหน้า
page_navigator($before_p,$plus_p,$total,$total_p,$chk_page);
?>
</div>
<?php } ?>
<div class="clear2"><br></div>
<?php
while($rs=mysql_fetch_array($qr)){
$id_product=$rs[id_product];
$code=sprintf("%05d",$id_product);
$name_product=$rs[name_product];
$id_brand=$rs[id_brand];
$price=$rs[price];
$photo=$rs[photo];
?>
<div id="productfiat">
<div class="photo_product">
<? if($photo==" " and ' ')
{ echo"$photo<img src='photo/photo_product/nopic.jpg' >";}
else {
echo "
<A href = 'type_step3_view.php?id_type=$id_type&id_sub_type=$id_sub_type&id_product=$id_product&id_sub_type2=$id_sub_type2' ><img src='photo/photo_product/$photo' width='120' height='95' border='0' alt='รายละเอียดสินค้า' /></a>"; }
?>
</div>
<div class="detail_product">
<h2><font color="#696969"> ชื่อสินค้า </font> : <font color="#0000"><? echo"$name_product"; ?></font></h2>
<br><? echo "
<A href = 'type_step3_view.php?id_type=$id_type&id_sub_type=$id_sub_type&id_product=$id_product&id_sub_type2=$id_sub_type2' ><img src='images/b2.jpg' alt='รายละเอียดสินค้า' border='0'/></a><A href='basket_add.php?id_product=$id_product'><img src='images/b4.jpg' alt='สั่งสินค้า' border='0'/></a> "; ?>
</div>
</div >
<div class="clear2"><br></div>
<?php } ?>
<?php if($total>0){ ?>
<div class="browse_page">
<?php
// เรียกใช้งานฟังก์ชั่น สำหรับแสดงการแบ่งหน้า
page_navigator($before_p,$plus_p,$total,$total_p,$chk_page);
?>
</div>
<?php } ?>
<div class="clear2"></div>
</div>
</div>
<div id="sidebar1">
<ul>
<li><a href="#"><img src="images/blue.jpg" height="30" width="141" border="0px"></a>
<?
$sql = " select id_sub_type,photo_sub_type from sub_type where id_type = '$id_type' and id_sub_type='$id_sub_type'" ;
$result = mysql_db_query($dbname,$sql ) ;
while ($rs= mysql_fetch_array ( $result ) ) {
$id_sub_type = $rs[id_sub_type];
$photo_sub_type = $rs[photo_sub_type];
echo "<li><center><a href = 'type_step3.php?id_type=$id_type&id_sub_type1=$id_sub_type'><img src = 'photo/menu_sub_type/$photo_sub_type' width='141' height='30' border='0px'></a></center></li>" ;
}
?>
<?
$sql = " select id_sub_type2,menu_sub_type2 from sub_type2 where id_sub_type2 = '$id_sub_type2'" ;
$result = mysql_db_query($dbname,$sql ) ;
while ($rs= mysql_fetch_array ( $result ) ) {
$id_sub_type2 = $rs[id_sub_type2];
$menu_sub_type2 = $rs[menu_sub_type2];
echo "<li><a href = 'type_step3-3.php?id_type=$id_type&id_sub_type=$id_sub_type&id_sub_type2=$id_sub_type2'><img src = 'photo/menu_sub_type2/$menu_sub_type2' width='141' height='30' border='0px'></a></li> " ;
}
?>
</ul>
<h2>Search Spec</h2>
<ul>
<?
//if ($id_sub_type2=="1"){include "composite_external_panal_search.php";}
//if ($id_sub_type2=="2"){include "composite_internal_panal_search.php";}
//if ($id_sub_type2=="3"){include "composite_fire_proof_search.php";}
//if ($id_sub_type2=="7"){include "lever_set_search.php";}
?>
</ul>
<div id="sidebarbtm"></div>
</div>
<div class="clear"></div>
</div>
<div id="footer"></div>
<div id="bottom">
<div id="underPanel">
<p><? include "under_menu.php"; ?></p>
</div>
<p><STRONG><font color="#999">Copyright © 2009 S.P.E. GROUP</font></STRONG></p>
<h3><center>438/12-13 Soi 24, Lardphrao Road, Jompol, Jatujak, Bangkok 10900<br />
Tel : 0-2938-1938, 0-2938-9292, 02511-3366 (24 Line) <br />
Fax : 0-2513-3070, 0-2511-3061 [email protected]</center></h3>
</div>
<? include"site_map.php"; ?>
</div>
</body>
</html>
ซึ่งพอผลที่ได้จะเป็นอย่างนี้อ่ะค่ะ http://naked13.50gigs.net/next.php
รบกวนพี่ๆช่วยหน่อยนะคะ(ได้โปรด)
Tag : - - - -
|
|
|
|
|
|
Date :
2009-11-28 15:22:15 |
By :
naked13 |
View :
912 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เห็นโค๊ดแบบนี้เค้าก็ถอยกันหมดแล้วครับน้อง อ่านแล้วมึนโค๊ด
เอาแบบสั้นๆ ตรงปัญหา ว่ามันเกิดอะไรขึ้น อยากได้แบบไหน ประมาณนี้อะครับ
|
|
|
|
|
Date :
2009-11-29 20:27:05 |
By :
plakrim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอโทษค่ะ ฟ้าลองเอาเว็บเพื่อนมาลองอัพขึ้น host อันนี้แล้ว มันก็ next ไม้ได้เหมือนกัน คงเป็นที่ host อ่ะค่ะ
(มันเป็นของฟรี)
ขอบคุณพี่ ปรากลิม มากๆนะคะ และทุกๆคนด้วยที่เข้ามาดูค่ะ
|
|
|
|
|
Date :
2009-11-29 22:01:29 |
By :
naked13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองใช้ $_POST $_GET ดูซิครับ host คงปิด register_global ไว้อะครับ
อยากรู้ว่ามันคืออะไร ค้นหาดูในบอร์ดนี้อะ เดี๋ยวเข้าใจเอง
|
|
|
|
|
Date :
2009-11-29 22:05:25 |
By :
plakrim |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|