|
 |
|
ขอความช่วยเหลือเกี่ยวกับ link คือ กรณีแสดงผลโดย code แบ่งหน้า จากการเรียกใช้ข้อมูล 3 ตาราง |
|
 |
|
|
 |
 |
|
คือ กรณีแสดงผลโดย code แบ่งหน้า จากการเรียกใช้ข้อมูล 3 ตาราง มันแสดงได้แล้วหมดแล้ว
แต่พอเอา ฟิลด์ในนั้นมาเป็น เมนู link มันกลับแสดงผลแค่หน้าแรก แล้วหน้าต่อไปกลับไม่
แสดงผลอ่ะค่ะ
Code (PHP)
<? include("connection.php"); ?>
<? include("header.php"); ?>
<?php
$strSQL = "SELECT * FROM product where typecode = '$tcode'";
$objQuery = mysql_query($strSQL);
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 6; // Per Page แสดงต่อ page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$Page_Start = (($Per_Page*$Page)-$Per_Page);
if($Num_Rows<=$Per_Page)
{
$Num_Pages =1;
}
else if(($Num_Rows % $Per_Page)==0)
{
$Num_Pages =($Num_Rows/$Per_Page) ;
}
else
{
$Num_Pages =($Num_Rows/$Per_Page)+1;
$Num_Pages = (int)$Num_Pages;
}
// code แบ่งหน้า
$sql="select product.productcode, product.productmodel, product.productname, product.productdetail, product.productpdf, product.productpicture, brand.brandname, type.typename from product , brand , type where product.typecode = type.typecode and product.brandcode = brand.brandcode and product.typecode = '$tcode' order by productcode LIMIT $Page_Start , $Per_Page ";
$result = mysql_db_query($dbname, $sql);
$num=mysql_num_rows($result );
if ($num>0) {
echo "<table border=1 cellpadding=5 cellspacing=5 bordercolor='#425452' background='images/bg5.gif'>";
$check=1;
while($rs=mysql_fetch_array($result)) {
$productcode=$rs[productcode];
$productcode=sprintf("%05d",$productcode);
$productmodel=$rs[productmodel];
$productname=$rs[productname];
$productdetail=$rs[productdetail];
$productpdf=$rs[productpdf];
$brandname=$rs[brandname];
$typename=$rs[typename];
$productpicture=$rs[productpicture];
if ($productpicture==" ") {
$productpicture="nopic.gif";
}
if ($check%2 == 1) {
echo "<tr>";
}
echo "
<td width='10%' valign='center'>
<img src='product/$productpicture' border='0' width=120 height=120>
</td>
<td width='30%' valign='top' class=textstyle>
<Font color='#0000FF'>รหัส : <Font color='#0000FF'>$productcode<br>
<Font color='#0000FF'>Model : <Font color='#0000FF'>$productmodel<br>
<Font color='#0000FF'>ชื่อสินค้า : <Font color='#000000'>$productname<br>
<Font color='#0000FF'>ยี่ห้อสินค้า : <Font color='#000000'> $brandname <br>
<Font color='#0000FF'>ประเภท : <Font color='#000000'> $typename <br>
<Font color='#0000FF'>รายละเอียด : <Font color='#000000'>$productdetail <br>
<Font color='#0000FF'>ไฟล์ PDF : <Font color='#000000'><a href='product/$productpdf' target='_blank'>Download</a><br>
<br>
</td>";
if ($check%2==0) {
echo "</tr>";
$check=0;
}
$check++;
}
echo "</table>";
}
?>
<!--แสดง linkแบ่งหน้า -->
<? echo"<span class='textstyle'>"; ?>
Total
<?= $Num_Rows;?>
Record :
<?=$Num_Pages;?>
Page :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
mysql_close();
?>
</table>
</td>
</tr>
</table>
</form>
<? include("footer.php"); ?>
วอนผู้รู้ช่วยดูให้หน่อยนะค่ะ ขอขอบคุณล่วงหน้ามา ณ ที่นี้ด้วยค่ะ
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-11-25 11:35:48 |
By :
virusbow |
View :
926 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ดูค่า Page=xx ว่ามีส่งไปหรือเปล่าน่ะครับ
|
 |
 |
 |
 |
Date :
2009-11-28 23:57:27 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มีค่าส่งไปค่ะ
|
 |
 |
 |
 |
Date :
2009-12-01 09:18:01 |
By :
virusbow |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|