Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > PHP > PHP Forum > มีปัญหาการแบ่งหน้าคะ คือว่ามันแบ่งหน้าให้แต่ข้อมูลที่เราต้องการมันไม่แบง่ทำไงดีคะไม่รู้ว่าผิดตรงไหนหรือเปล่าช้าวยหน่อยนะคะ



 

มีปัญหาการแบ่งหน้าคะ คือว่ามันแบ่งหน้าให้แต่ข้อมูลที่เราต้องการมันไม่แบง่ทำไงดีคะไม่รู้ว่าผิดตรงไหนหรือเปล่าช้าวยหน่อยนะคะ

 



Topic : 019623

Guest




คือว่ามันแบ่งหน้าให้แต่ข้อมูลที่เราต้องการมันไม่แบง่ทำไงดีคะไม่รู้ว่าผิดตรงไหนหรือเปล่าช้าวยหน่อยนะคะ


<?
session_start();
if ($sess_adminid<>session_id()) {
header( "Location: index.php"); exit();
}

$hostname ="localhost";
$user="root";
$password="";
$dbname="shop";
$tblname="type";
mysql_connect($hostname,$user,$password)or die("ติดต่อฐานข้อมูลไม่ได้");
mysql_select_db($dbname)or die("เลือกฐานข้อมูลไม่ได้");
$char_set ="SET NAMES 'tis620'";
mysql_query($char_set);
//เลือกตาราง
$sql= 'SELECT * FROM type order by id_type asc';
$result = mysql_query($sql);
if (!$result) {
die('Invalid query: ' . mysql_error());
exit;
}
//พิมพ์ตารางออกมา
echo "<center>";
?>
<?
/* ตั้งค่า แสดงผลต่อหน้า $Per_Page */
$Per_Page =2;
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;
if(($Page>$Num_Pages) || ($Page<0))
print "<center><b>จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ<b></center>";
$sql = "select * From type order by id_type asc LIMIT $Page_start , $Per_Page";?>
<div align="center"><br>
มีจำนวน Recored ทั้งหมด
<?= $Num_Rows;?>
รวมทั้งหมด : <b>
<?=$Num_Pages;?>
</b> หน้า :
<?/* สร้างปุ่มย้อนกลับ */
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'>$i</a>]";
else
echo "<b> $i </b>";
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages)
echo "<a href ='$PHP_SELF?Page=$Next_Page'> หน้าถัดไป>> </a>";

?>

<?
include "connect.php";
$id_type_select=$_GET[id_type];
$page=$_GET[page];
if($page==""){
$page=1;
}
$each=18;
?>

<html>
<head>
<title>ระบบร้านค้าขายของชำ</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<style type="text/css">
<!--
.style1 {font-family: "MS Sans Serif"}
body {
margin-top: 0px;
}
.style85 {color: #009900}
a:link {
color: #009900;
text-decoration: none;
}
a:visited {
color: #009900;
text-decoration: none;
}
a:hover {
color: #0000FF;
text-decoration: none;
}
a:active {
color: #009900;
text-decoration: none;
}
-->
</style>
</head>

<body>
<form name="form1" method="post" action="">
<table width="803" height="815" border="0" align="center" cellpadding="0" cellspacing="0" background="picture/bgweb1.jpg">
<tr>
<td width="148" valign="top"></td>
<td width="72" valign="top"></td>
<td width="192" valign="top"></td>
<td colspan="2" valign="top"></td>
</tr>
<tr>
<td height="208" valign="top"></td>
<td valign="top"></td>
<td valign="top"></td>
<td colspan="2" valign="top"></td>
</tr>
<tr>
<td rowspan="5" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="35" align="right"><a href="type.php">หน้าหลัก</a><a href="first.php"><br />
<br />
</a></td>
</tr>
<tr>
<td align="right"><a href="member.php">ข้อมูลลูกค้า<br />
<br />
</a></td>
</tr>
<tr>
<td align="right"><a href="type.php" class="style85">ประเภทสินค้า</a><br />
<br /></td>
</tr>
<tr>
<td align="right"><a href="product.php">สินค้า</a><a href="product.php"><br />
<br />
</a></td>
</tr>
<tr>
<td align="right"><a href="agent.php">ตัวแทนจำหน่าย</a><a href="agent.php"><br />
<br />
</a></td>
</tr>
<tr>
<td align="right"><a href="buy.php" class="style85">การซื้อสินค้า</a><br />
<br /></td>
</tr>
<tr>
<td align="right"><span class="style85"><a href="sale.php">การขายสินค้า</a></span><br />
<br /></td>
</tr>
<tr>
<td align="right"><a href="index.php" class="style85">ออกจากระบบ</a><br />
<br /></td>
</tr>
</table></td>
<td height="48" valign="top"></td>
<td valign="top"><span class="style85"> <a href="type.php">เพิ่มประเภทสินค้า</a></span></td>
<td width="183" valign="top"><a href="showtype.php" class="style85">แสดงประเภทสินค้า</a></td>
<td width="208" valign="top"><a href="serach">ค้นหาประเภทสินค้า</a>
</tr>
<tr>
<td valign="top"></td>
<td colspan="3" valign="top"><div align="center"></div></td>
</tr>
<tr>
<td valign="top"></td>
<td colspan="3" rowspan="2" valign="top"><a href="showtype.php"></a>
<table width="200" border="1">
</table>
<table width="85%" border="2" align="center" cellspacing="2" bordercolor="#FF99FF">
<tr>
<td width="11%" align="center" bgcolor="#FF99FF"><div align="center"><strong>รหัสประเภทสินค้า</strong></div></td>
<td width="21%" align="center" bgcolor="#FF99FF"><div align="center"><strong>ประเภทสินค้า</strong></div></td>
<td width="8%" align="center" bgcolor="#FF99FF"><div align="center"><strong>แก้ไข</strong></div></td>
<td width="8%" align="center" bgcolor="#FF99FF"><div align="center"><strong>ลบ</strong></div></td>
</tr>
<?
$no=1;
while($rs = mysql_fetch_array($result)) {
$id_type=$rs[id_type];
$name_type=$rs[name_type];

echo "
<tr bgcolor='#FFFFFF'>
<td><center>$id_type</center></td>
<td>$name_type</td>
<td><a href=\"type_edit.php?id_edit=$id_type\">แก้ไข</a></td>
<td><a href=\"deletetype.php?id_del=$id_type\"
onclick=\"return confirm('ยืนยันลบประเภทสินค้า $name_type ออกจากระบบ')\">ลบ</a></td>

</tr>";
$no++;
}
mysql_close();

?>

</table></td>
</tr>
<tr>
<td valign="top"></td>
</tr>
<tr>
<td valign="top"></td>
<td valign="top"></td>
<td colspan="2" valign="top"></td>
</tr>
</table>
<br>
<br>
<br>
<br>
<br>
<br>
</form>
<h3 align="left" class="style1"></h3>
<h3 align="center" class="style1"></h3>

</body>
</html>




Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 23 เม.ย. 2551 12:09:20 By : ไหมเงิน View : 1287 Reply : 2
 

 

No. 1

Guest


จากที่ดูโค้ด Num_Rows ของคุณ ใฃ้ตอน select * from type order by id_type asc เท่านั้น

แต่ตอนหลัง คุณใช้ limit ตอนนี้แหละ คุณไม่ mysql_query ตัวนี้อีกที งั้นแบบนี้ มันก็ไม่แบ่งหน้าให้สิครับ มันก็ ใช้ order by id_type ตอนแรก เท่านั้นเอง แบบนี้ ถึงกดลิงค์หน้าไป มันก็ไม่มีผลอะไรเลยครับ
Num_Rows ตอนแรกนั้น แค่เพื่อให้รู้ว่า ข้อมูลทั้งหมดมีเท่าไหร่ แล้วก็ทำการคำนวณแบ่งหน้าออกมา แล้วมันจะ select ตอนหลังอีกที โดยใช้ limit นั่นแหละ ตรงนี้คือ จุดสำคัญของการแบ่งหน้านะครับ เพราะฉะนั้น เราต้องเอา ข้อมูลของ การ select ตรงนี้มาใช้งาน

ลองทำตามที่ผมบอกดูนะครับ






Date : 23 เม.ย. 2551 12:30:44 By : ผู้ไม่ประสงค์นาม
 


 

No. 2

Guest


ขอบคุณมากคะสำหรับคำแนะนำ แต่ช่วยแก้ให้หน่อยได้ไหมคะว่าจะต้งเพิ่มที่ส่วนไหนยัไง เพราะลองแก้แล้วไม่รู้ว่าต้องแก้ยังวไงคะ
ขอบคุณคะ
Date : 24 เม.ย. 2551 14:13:04 By : ไหมเงิน
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : มีปัญหาการแบ่งหน้าคะ คือว่ามันแบ่งหน้าให้แต่ข้อมูลที่เราต้องการมันไม่แบง่ทำไงดีคะไม่รู้ว่าผิดตรงไหนหรือเปล่าช้าวยหน่อยนะคะ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 00
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่