ขอรบกวนอีกครั้งครับอาจารย์ แบ่งหน้าครับผม

ขอบคุณครับอาจารย์ ขอรบกวนอีกครั้งน่ะครับผม พอดีมันยังไม่ได้อะครับ
คือว่า ผม query สองครั้ง ครั้งที่ 1 query เอาเฉพาะประเภทเอกสาร
<?
// query เอาประเภทเอกสาร
$doctype_sql="select * from document_recive inner join document_type on mid(document_recive.doc_regis,1,1)=document_type.doc_no_type where document_recive.depart_recive='$_SESSION[depart]' ";
          $doctype_sql.=" group by mid(document_recive.doc_regis,1,1)";
          $doctype_result=mysql_query($doctype_sql);
echo "<table>......................";
while($fechtdoc=mysql_fetch_array($doctype_result)) {
         $doc_type_no=$fechtdoc['doc_no_type'];//------ประเภทเอกสาร
?>

//------query ครั้งที่ 2 query เอารายการเอกสารทั้งหมด แสดงตามเงื่อนไข
<?
$sql="SELECT
document_recive.doc_no,
document_recive.doc_regis,
document_recive.depart_recive,
document_recive.date_recive,
document_recive.time_recive,
document_recive.`status`,
document_recive.id,
document_recive.user_recive,
document.doc_id,
document.doc_date,document.doc_type,
document.desciption,document.doc_from
FROM
document_recive
Inner Join document ON document_recive.doc_no = document.doc_no";

$_GET['Page'];
$_GET['pagetype'];

if($_GET['pagetype'] =="") {
$sql.=" WHERE mid(document_recive.doc_regis,1,1) = '$doc_type_no'";// where เอกสารลงรับโดยแยกตามประเภทเอกสาร
} else {
$sql.=" WHERE mid(document_recive.doc_regis,1,1) = '$pagetype'";
       }
$sql.=" order by CAST(document_recive.id AS SIGNED) DESC";
//-----------กำหนดแสดงหน้า
$Per_Page =10;
if(!$Page)
$Page=1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$result = mysql_query($sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
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;
$sql.=" LIMIT $Page_start , $Per_Page";
$result=mysql_query($sql);   
$numrows=mysql_num_rows($result);
           
while($n=mysql_fetch_array($result)) {
echo "........รายการเอกสารที่แสดงตามประเภทเอกสาร..........................";
      } ปิดรูปรายการเอกสารแสดงตามประเภทเอกสาร
echo "</table>";
} // ปิดรูปประเภทเอกสาร
?>

//--------------------------------next page--------------
<? /* สร้างปุ่มย้อนกลับ */

if($Prev_Page)
echo " <a href='$PHP_SELF?Page=$Prev_Page'><< ย้อนกลับ </a>";
for($i=1; $i<$Num_Pages; $i++){
if($i != $Page)
//echo '[<a href="$PHP_SELF?Page='.$i.'&amp;pagetype='.$doc_type_no.'">'.$i.'</a>]'; // โค้ดแบ่งหน้า
echo "[<a href='$PHP_SELF?Page=$i&amp;pagetype=$doc_type_no&amp;next2=$next1'>$i</a>]";//-------------- ส่งประเภทเอกสารไปด้วย
else
echo "<b> $i </b>";
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages)
echo "<a href ='$PHP_SELF?Page=$Next_Page'> หน้าถัดไป>> </a>";

?>

ขอรบกวนอีกครั้งน่ะครับผมอาจารย์ ขอบคุณครับ
18 มิ.ย. 2552 1 2,334

ที่ผมไม่ได้ตอบก็เพราะ ขี้เกียจดูโค้ด และก็ไม่ค่อยเข้าใจเท่าไหร่ว่าติดตรงไหน ช่วยสรุปอีตรงที่ติดมาอีกสักที เพื่อให้ผมตอบได้ตรงคำถามยิ่งขึ้น
#1
ความคิดเห็น
ไฟล์อัปโหลด ชนิด jpg, jpeg ขนาดไฟล์ไม่เกิน 1024
^