|
 |
|
ช่วยด้วยค่ะ พอดีทำทำList ข้อมูลแบบPaging(แบ่งหน้า) จากการค้นหาโดยใช้ list menu แล้วเวลาเลือกหน้าถัดไปแล้วมีปัญหาค่ะ |
|
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2012-06-24 07:33:19 |
By :
roongyo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือว่าเมื่อวานลองแก้ไขทั้งวันแล้วทำไม่ได้ค่ะยังเป็นเหมืือนเดิม รบกวนผู้รู้ช่วยหน่อยน่ะค่ะ ขอบคุณมากค่ะ
Code (PHP)
<html>
<head>
<title>Test</title>
</head>
<body>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="599" border="1">
<tr>
<th>Select
<select name="ddlSelect" id="ddlSelect">
<option selected>- เลือกประเภทการค้นหา -</option>
<option value="pbw_dep" <? if($_GET["ddlSelect"]=="pbw_dep"){echo"selected";}?>>รหัสหน่วยงาน</option>
<option value="pbw_dep_name" <? if($_GET["ddlSelect"]=="pbw_dep_name"){echo"selected";}?>>ชื่อหน่วยงาน</option>
<option value="pbw_date" <? if($_GET["ddlSelect"]=="pbw_date"){echo"selected";}?>>วันที่</option>
<option value="pbw_pro_id" <? if($_GET["ddlSelect"]=="pbw_pro_id"){echo"selected";}?>>รหัสโปรแกรม</option>
<option value="pbw_pro_name" <? if($_GET["ddlSelect"]=="pbw_pro_name"){echo"selected";}?>>ชื่อโปรแกรม</option>
</select>
</select>
Keyword
<input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>">
<input type="submit" name="Search" id="Search" value="Search"></th> //----> ใส่ Name และ ID เพื่อเรียกใช้งานได้ถูกต้อง
</tr>
</table>
</form>
<?
if($_GET['txtKeyword'] != "")
{
include ("dbconn3.inc.php");
@mysql_query("SET NAMES UTF8");
$del = $_GET['ddlSelect'];
$strSQL = "select pbw_id,pbw_date,pbw_dep,pbw_dep_name,pbw_pro_id,pbw_pro_name,pbw_user,pwd_img,pbw_status from problem_w where 1 AND pbw_status = '0' ";
if($del != "" and $Search != '')
{
$strSQL .= " AND (".$del." LIKE '%".$_GET["txtKeyword"]."%' ) ";
}
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 3; // 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 pbw_id LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table align=\"center\" width=\"1200\" border=\"0\" cellpadding=\"1\" cellspacing=\"1\">
<tr bgcolor="#CCFFFF" >
<td width="80" align="center" bgcolor="#66CCFF">ลำดับที่</td>
<td width="90" align="center" bgcolor="#66CCFF">ว/ด/ปที่แจ้ง</td>
<td width="120" align="center" bgcolor="#66CCFF">รหัสหน่วยงาน</td>
<td width="120" align="center" bgcolor="#66CCFF">ชื่อหน่วยงาน</td>
<td width="130" align="center" bgcolor="#66CCFF">รหัสโปรแกรม</td>
<td width="200" align="center" bgcolor="#66CCFF">ชื่อโปรแกรม</td>
<td width="100" align="center" bgcolor="#66CCFF">ผู้แจ้ง</td>
<td width="70" align="center" bgcolor="#66CCFF">ไฟล์ doc</td>
<td width="90" align="center" bgcolor="#66CCFF">ภาพ</td>
<td width="30" align="center" bgcolor="#66CCFF">ลบ</td>
</tr>
<?
while($row = mysql_fetch_array($objQuery))
{
?>
<tr>
<td align="center"><?=$row["pbw_id"];?></td>
<td align="center"><?=$row["pbw_date"];?></td>
<td align="center"><?=$row["pbw_dep"];?></td>
<td align="center"><?=$row["pbw_dep_name"];?></td>
<td align="center"><?=$row["pbw_pro_id"];?></td>
<td align="center"><?=$row["pbw_pro_name"];?></td>
<td align="center"><?=$row["pbw_user"];?></td>
<td align="center"><a href="printdoc.php?pbw_id=<?=$row["pbw_id"];?>">ไฟล์์</a></td>
<td align="center"><a href="captures/<?=$row["pwd_img"];?>" onclick=""> <?=$row["pwd_img"];?></td>
<td align="center"> <span id="row table color"><a href="pro_detaildelete.php?pbw_id=<?=$row['pbw_id'];?>" onClick="return confirm('ต้องการลบข้อมูลหรือไม่');">ลบ</a></span></td>
</tr>
<?
}
?>
</table>
<br>
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? //ถถูฏ?>
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=$_GET[txtKeyword]'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_GET[txtKeyword]'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{//
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_GET[txtKeyword]>Next>></a> ";
}
}
@mysql_close;
?>
</body>
</html>
|
ประวัติการแก้ไข 2012-06-24 07:37:55
 |
 |
 |
 |
Date :
2012-06-24 07:36:40 |
By :
roongyo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณจะต้องส่งค่า $_GET['ddlSelect'] ไปกับ URL ด้วยน่ะครับ เหมือนพวกนี้
Code (PHP)
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=$_GET[txtKeyword]'><< Back</a> ";
ลองดูครับ ไม่ยากแค่เพิ่มนิดหน่อย
|
 |
 |
 |
 |
Date :
2012-06-24 07:37:56 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากค่ะคุณวิน เดี๋ยวจะลองทำดูนะค่ะ
|
 |
 |
 |
 |
Date :
2012-06-24 07:39:13 |
By :
roongyo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คุณวินค่ะ ใส่แล้วยังเป็นเหมือนเดิมค่ะ รบกวนดูให้หน่อยนะค่ะ
Code (PHP)
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? //ถถูฏ?>
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&ddlSelect=$_GET[ddlSelect]&txtKeyword=$_GET[txtKeyword]'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&ddlSelect=$_GET[ddlSelect]&txtKeyword=$_GET[txtKeyword]'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{//
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&ddlSelect=$_GET[ddlSelect]&txtKeyword=$_GET[txtKeyword]>Next>></a> ";
}
|
 |
 |
 |
 |
Date :
2012-06-24 07:43:02 |
By :
roongyo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตอนที่คลิกไปหน่า 2 คุณดูที่ URL มันมีค่าหรือเปล่าครับ
|
 |
 |
 |
 |
Date :
2012-06-24 07:47:06 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หน้าแรกค่ะ
http://localhost/himsproblem/sssssssss.php?ddlSelect=pbw_dep&txtKeyword=DIU&Search=Search
หน้าที่ 2 นะค่ะ
http://localhost/himsproblem/sssssssss.php?Page=2&txtKeyword=DIU
|
 |
 |
 |
 |
Date :
2012-06-24 07:50:39 |
By :
roongyo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันไม่มีตัวแปร ddlSelect เลยครับ ตรวจสอบให้ดีครับ
|
 |
 |
 |
 |
Date :
2012-06-24 07:58:07 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หน้าที่ 3 ค่ะ

ผลลัพธ์ดัน ไม่ตรงกับที่จะหาเลยค่ะ งงมาก
|
ประวัติการแก้ไข 2012-06-24 08:03:22
 |
 |
 |
 |
Date :
2012-06-24 08:02:08 |
By :
roongyo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองไล่ดูดี ๆ ก่อนค่อยถามอีกครับ 
|
 |
 |
 |
 |
Date :
2012-06-24 08:03:58 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ว่าแล้ว
|
 |
 |
 |
 |
Date :
2012-06-24 16:39:41 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|