|
|
|
มีปัญหาเรื่องแบ่งหน้าค่ะ คือตอนค้นหามันก็แบ่งหน้าให้ปกติ แต่พอกดหน้า2 มันไม่ตรงตามที่ค้นหาในตอนแรก |
|
|
|
|
|
|
|
รบกวนดูให้หน่อยน่ะค่ะว่าต้อแก้ต้องปรับตรงไหน ขอบคุณค่ะ
Code (PHP)
<table width="580" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top"> </td>
</tr>
<tr>
<td align="center" valign="top"><span class="style10">สถานะโครงการ/แผนงานประจำ ที่เสนอ</span></td>
</tr>
<tr>
<td align="center" valign="top"> </td>
</tr>
<tr>
<td align="center" valign="top"></td>
</tr>
<tr>
<td align="center" valign="top"><form name="frmSearch" method="post" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="496" border="0" align="center">
<tr>
<th width="107" align="left" valign="middle" class="style6 style59">ชื่อโครงการ</th>
<th align="left" valign="middle" class="style6"><span class="style37">
</span><span class="style37"><span class="style9">
<input name="name" type="text" id="name" value="" size="45" />
</span>
</span></th>
<th width="54" align="left" valign="middle" class="style6"><span class="style37">
</span></th>
</tr>
<tr>
<th align="left" valign="middle" class="style6 style59">ฝ่าย/สาขา</th>
<th align="left" valign="middle" class="style6"><span class="style37"><span class="style9">
<select name="lmName">
<option value="" selected>--ระบุฝ่าย/สาขา--</option>
<?
$strSQL1 = "SELECT * FROM pgroup ";
$objQuery1 = mysql_query($strSQL1);
while($objResuut1 = mysql_fetch_array($objQuery1))
{
?>
<option value="<?=$objResuut1["id_pgroup"];?>">
<?=$objResuut1["name_pgroup"];?>
</option>
<?
}
?>
</select>
</span>
</span><span class="style37"><span class="style9">
</span>
</span></th>
<th width="54" align="left" valign="middle" class="style6"> </th>
</tr>
<tr>
<th align="left" valign="middle" class="style6 style59">ปีการศึกษา</th>
<th align="left" valign="middle" class="style6"><span class="style37"><span class="style9">
<input name="year" type="text" id="year" value="" size="8" />
</span></span></th>
<th align="left" valign="middle" class="style6"> </th>
</tr>
<tr>
<th align="left" valign="middle" class="style6 style59"> </th>
<th align="left" valign="middle" class="style6"><span class="style37">
<input name="submit" type="submit" value="ค้นหา" />
</span></th>
<th align="left" valign="middle" class="style6"> </th>
</tr>
</table>
</form></td>
</tr>
<tr>
<td align="center" valign="top"><span class="style8"><span class="style78"> <span class="style7"><span class="style22">
<?
$name = $_POST['name'];
$year = $_POST['year'];
$name_pgroup = $_POST['lmName'];
$strSQL2 = "SELECT * FROM project WHERE 1 ";
if($_POST["name"] != "")
{
$strSQL2 .= " AND name like '%".$_POST["name"]."' ";
}
if($_POST["year"] != "")
{
$strSQL2 .= " AND year like '%".$_POST["year"]."' ";
}
if($_POST["lmName"] != "")
{
$strSQL2 .= " AND owner = '".$_POST["lmName"]."' ";
}
$objQuery2 = mysql_query($strSQL2) or die ("Error Query [".$strSQL2."]");
$Num_Rows = mysql_num_rows($objQuery2);
$Per_Page = 2; // 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;
}
$strSQL2 .=" LIMIT $Page_Start , $Per_Page";
$objQuery2 = mysql_query($strSQL2);
$a=1;
?>
</span></span> </span></span></td>
</tr>
<tr>
<td align="center" valign="top"> </td>
</tr>
<tr>
<td align="center" valign="top"><table width="590" border="1" align="center" cellpadding="0" cellspacing="1" bordercolor="#999999">
<tr align="center" bgcolor="#2F97E0" class="style8">
<td width="239" height="25"><span class="style78"> โครงการ
/<br>
แผนงานประจำ </span></td>
<td width="120"><span class="style78">ผู้รับผิดชอบ</span></td>
<td width="75"><span class="style78">งบประมาณ</span></td>
<td width="55"><span class="style78">ฝ่ายแผน</span></td>
<td width="55"><span class="style78">ผอ.</span></td>
<td width="25"> </td>
</tr>
<?
while($objResult2 = mysql_fetch_array($objQuery2))
{
?>
<tr align="center" valign="top" bgcolor="#FFFFFF" >
<td height="20" align="left"><span class="style59">
<?=$objResult2["name"];?>
</span></td>
<td align="left" class="style59" >
<? $owner=$objResult2["owner"];?>
<?
$strSQL3 = "SELECT * FROM pgroup WHERE id_pgroup = '$owner'";
$objQuery3 = mysql_query($strSQL3) or die ("Error Query [".$strSQL3."]");
$objQuery3 = mysql_query($strSQL3);
$objResult3 = mysql_fetch_array($objQuery3);
?>
<?=$objResult3["name_pgroup"];?> </td>
<td align="right" ><span class="style59">
<?
$status_plan=$objResult2["status_plan"];
$status_manager=$objResult2["status_manager"];
$budget=$objResult2["budget"]; echo number_format($budget,2);
if($status_plan == 'อนุมัติ' && $status_manager =='อนุมัติ')
{
$sumbudget=$sumbudget+$budget;
}
?>
</span> </td>
<td align="center" ><span class="style59">
<? $status_plan=$objResult2["status_plan"];
if($status_plan == "ไม่อนุมัติ")
{
$id_project=$objResult2["id_project"];
echo "<a href=JavaScript: onClick=window.open('title1.php?id_project=$id_project','','width=700,height=350');><font color=red>$status_plan</font></a>";
}
else if($status_plan == "อนุมัติ")
{
echo "<font color=green>$status_plan</font>";
}
else
{
echo $status_plan;
}
?>
</span></td>
<td align="center" ><span class="style59">
<? $status_manager=$objResult2["status_manager"];
if($status_manager == "ไม่อนุมัติ")
{
$id_project=$objResult2["id_project"];
echo "<a href=JavaScript: onClick=window.open('title2.php?id_project=$id_project','','width=700,height=350');><font color=red>$status_manager</font></a>";
}
else if($status_manager == "อนุมัติ")
{
echo "<font color=green>$status_manager</font>";
}
else
{
echo $status_manager;
}
?>
</span></td>
<td align="center" ><span class="style100"><span class="style85">
<? $id_project=$objResult2["id_project"];
echo"<a href=project_view.php?id_project=$id_project target=_blank ><img src=pic/document_view.png title=รายละเอียด></a>";?>
</span></span></td>
</tr>
<? $a++;} ?>
<tr align="center" valign="top" bgcolor="#FFFFFF" >
<td height="20" colspan="2" align="right"><span class="style104">งบประมาณที่ใช้ </span></td>
<td colspan="4" align="center" valign="middle" ><span class="style104"><? echo number_format($sumbudget,2) ; ?> บาท</span></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" valign="top"> </td>
</tr>
<tr>
<td align="center" valign="top" class="style80"><strong> <strong> <span class="style85"><span class="style12"><span class="style4 style50"><strong>Total</strong>
<?= $Num_Rows;?>
<strong>Record</strong>
</span></span></span></strong></strong><span class="style13"><span class="style12"><span class="style50 style80"><span class="style11">
<?
$pages = new Paginator;
$pages->items_total = $Num_Rows;
$pages->mid_range = 10;
$pages->current_page = $Page;
$pages->default_ipp = $Per_Page;
$pages->url_next = $_SERVER["PHP_SELF"]."?QueryString=value&Page=";
$pages->paginate();
echo $pages->display_pages()
?>
</span></span></span></span></td>
</tr>
</table>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2013-09-18 14:03:12 |
By :
sumonrat |
View :
620 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ส่งค่าที่ต้องเอาไป Query ผ่านลิ้ง page ไปด้วยครับ
|
|
|
|
|
Date :
2013-09-18 14:11:36 |
By :
mangkunzo |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 03
|