|
 |
|
มีปัญหาเรื่องโค้ด php การแบ่งหน้าพอคลิกไปหน้าที่ 2 ข้อมูลไม่ขึ้นคะ รบกวนด้วยนะคะ |
|
 |
|
|
 |
 |
|

ผลการค้นหาข้อมูลหน้า 1

ผลการค้นหาข้อมูลหน้า 2 มีปัญหาหน้านี้อ่ะคะ คือข้อมูลมันมี 11 รายการแต่พอคลิกไปที่หน้า 2 กลับไม่มีข้อมูลเหมือนกับว่ามันไม่ได้ส่งตัวแปรไปด้วยอ่ะคะ หนูต้องทำยังไงอ่ะคะ รบกวนด้วยนะคะ
free.php
Code (PHP)
<?
$colname = "-1";
if (isset($_POST['username'])) {
$colname = $_POST['username'];
$sql.= " and am.username = '$_POST[username]'";
}
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("db_pums");
mysql_query("SET NAMES UTF8");
$strSQL = "SELECT br.book_req_id,br.book_no, br.book_no_recevied ,br.date_recevied, br.date_export,br.status_id,br.bh_no,br.bk_no, br.kk_no,mov.ORG_ABBR,ss.status_name,am.first_name ,am.last_name FROM book_req br , mbt_org_v mov , system_status ss , admin am WHERE br.status_id = ss.status_id and mov.org_code = br.kk_no and br.username = am.username and am.username = '$_POST[username]' ";
$strSQL.=$sql;
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 10; // Per 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;
}
$strSQL .=" order by date_recevied DESC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table width="930" align="center" class="altrowstable" id="alternatecolor">
<tr>
<th width="33">ที่</th>
<th width="103">ผู้รับผิดชอบ</th>
<th width="129">เลขที่หนังสือ</th>
<th width="108">เลขที่หนังสือรับ</th>
<th width="104">วันที่รับ</th>
<th width="101">วันที่ส่ง</th>
<th width="281">สังกัด</th>
<th width="72">สถานะ</th>
</tr>
<?
$i = 1;
if($Page > 1){
$i = ($Per_Page * ($Page-1)) + 1;
}
if($Num_Rows=='0'){
echo"<h2>ไม่พบข้อมูล</h2>";
}
else{
echo"<h2>ผลการค้นหาข้อมูล";?> <a href="projectpolis/report2.php?username=<?=$_POST['username']?>">
<img src="image/print.png" alt="สั่งพิมพ์" width="36" height="36" align="absbottom" /></a><?
}
while($objResult = mysql_fetch_array($objQuery)){
?>
<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
<td align="center"><?=$i;?></td>
<td align="center"><?=$objResult
["first_name"];?></td>
<td align="center"><?=$objResult
["book_no"];?></td>
<td align="center"><?=$objResult
["book_no_recevied"];?></td>
<td align="center"><?=$objResult
["date_recevied"];?></td>
<td align="center"><?=$objResult
["date_export"];?></td>
<td align="left"><?=$objResult
["ORG_ABBR"];?></td>
<td align="center"><?=$objResult
["status_name"];?></td>
</tr>
<?
$i++;
}
?>
</table>
<p align="center">
<p align="center">ข้อมูลทั้งหมด
<?= $Num_Rows;?> รายการ : <?=$Num_Pages;?> หน้า :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< ย้นกลับ</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'>ถัดไป>></a> ";
}
mysql_close($objConnect);
?>
search_admin_admin.php
Code (PHP)
<form id="form1" name="form1" method="post" action="free.php" target="_blank">
<table width="850" height="157" align="center">
<tr>
<td width="149" scope="row"> </td>
<td width="279"> </td>
<td> </td>
</tr>
<tr>
<td colspan="2" scope="row"><H2>ค้นหาข้อมูลเจ้าหน้าบันทึกข้อมูล</H2></td>
<td width="406"> </td></tr>
<tr>
<td align="right">ชื่อเจ้าหน้าที่:</td>
<td><select name="username" id="username">
<?php do { ?>
<option value="<?php echo $row_admin['username']?>"><?php echo $row_admin['first_name'].' '.
$row_admin['last_name'] ?></option>
<?php }
while ($row_admin = mysql_fetch_assoc($admin));
$rows = mysql_num_rows($admin);
if($rows > 0) {
mysql_data_seek($admin, 0);
$row_admin = mysql_fetch_assoc($admin);
}
?>
</select></td>
<td> </td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnSearch" id="btnSearch" value=" ค้นหา" /></td>
<td> </td></tr>
</table>
</form>
Tag : PHP, MySQL, HTML/CSS, JavaScript, Ajax, jQuery

|
|
 |
 |
 |
 |
Date :
2012-10-05 09:53:15 |
By :
custer |
View :
1653 |
Reply :
5 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตกลงเป็หน้าค้นหา ??
แล้วพบข้อมูล 11 รายการ โดยให้แสดงหน้าละ 10 เรคคอร์ด
ไม่รู้ว่าได้รึป่าว นะ 
บรรทัดที่ 116Code (PHP)
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&&idb=<?php $objResult["book_no"];?>'>$i</a> ]";
|
ประวัติการแก้ไข 2012-10-05 10:03:09
 |
 |
 |
 |
Date :
2012-10-05 09:56:07 |
By :
compiak |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
บรรทัด 106 โทดทีๆ
|
 |
 |
 |
 |
Date :
2012-10-05 10:06:54 |
By :
compiak |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แนะนำนะครับ ตรงช่อง search ให้กำหนด value เอาครับ
เช่น value="<?=$textsearch;?>"
แล้วตอนรับก็ $_REQUEST[textsearch]
ตอนแบ่งหน้าลองดู แก้ให้ใหม่ อิอิ ไม่รู้ได้ป่าว
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&&search=<?php $_REQUEST[textsearch];?>'>$i</a> ]";
Go to : PHP MySQL Search Record Paging/Pagination
|
ประวัติการแก้ไข 2012-10-05 10:18:10
 |
 |
 |
 |
Date :
2012-10-05 10:14:21 |
By :
compiak |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|