|
|
|
รบกวนดูให้หน่อยค่ะ คือกดไปอีกหน้าแล้วไม่แสดงผลค่ะ แต่สามารถเห็นหน้าแรกเพียงหน้าเีดียว |
|
|
|
|
|
|
|
ได้แล้วค่ะ
Code (PHP)
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<script href="bootstrap1/js/bootstrap.min.js" rel="stylesheet"></script>
<link href="bootstrap1/css/bootstrap.min.css" rel="stylesheet">
<link href="bootstrap1/css/bootstrap-responsive.min.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-1.7.min.js" ></script>
</head>
<body>
<br/>
<center>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<fieldset>
Search : <input class="input-medium search-query" name="txtKeyword" id="txtKeyword" type="text" value="<?=$_GET["txtKeyword"];?>"/>
</fieldset>
<br/>
<input type="checkbox" name="Language" id="Language" value="th">
<select name="Lang">
<option value="" >Select Language</option>
<option value="android">android</option>
<option value="java">java</option>
</select>
<input type="checkbox" name="Advisor" id="Advisor" value="th">
<select name="Adv">
<option value="">Select Advisor</option>
<option value="A">a</option>
<option value="B">b</option>
</select>
<br/>
<input type="submit" name="Submit" value="Submit" class="btn">
<br/> <br/><br/>
</form>
</center>
<script>
$(document).ready(function(){
unlock();
$("[name=Language]").change(function(){
unlock();
});
});
function unlock(){
if($("[name=Language]").is(':checked')){
$("[name=Lang]").attr("disabled",false);
}
else{
$("[name=Lang]").attr("disabled",true);
}
}
///////////////////////////////////////////////
$(document).ready(function(){
unlock1();
$("[name=Advisor]").change(function(){
unlock1();
});
});
function unlock1(){
if($("[name=Advisor]").is(':checked')){
$("[name=Adv]").attr("disabled",false);
}
else{
$("[name=Adv]").attr("disabled",true);
}
}
</script>
</body>
</html>
<?
if(!$_GET["Page"])
{
$Page=1;
} else {
$Page = $_GET["Page"];
}
echo $Page;
$objConnect = mysql_connect("localhost","root","123") or die("Error Connect to Database");
$objDB = mysql_select_db("test");
$strSQL = "SELECT * FROM test";
if($_GET["txtKeyword"] != "")
{
$strSQL .= " WHERE (Name LIKE '%".$_GET["txtKeyword"]."%')";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 1; // Per Page
$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 ID ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table class="table" width="600">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Language </div></th>
<th width="97"> <div align="center">Advisor </div></th>
<th width="97"> <div align="center">Proj </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$objResult["ID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Language"];?></td>
<td><div align="center"><?=$objResult["Advisor"];?></div></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]&Lang=$_GET[Lang]&Adv=$_GET[Adv]'><< Back</a>";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_GET[txtKeyword]&Lang=$_GET[Lang]&Adv=$_GET[Adv]'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_GET[txtKeyword]&Lang=$_GET[Lang]&Adv=$_GET[Adv]'>Next>></a> ";
}
mysql_close($objConnect);
?>
<?
}else{
$strSQL .= " WHERE (Language LIKE '%".$_GET["Lang"]."%' and Advisor LIKE '%".$_GET["Adv"]."%')";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$Per_Page = 1; // Per Page
$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 ID ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
?>
<table class="table" width="600">
<tr>
<th width="91"> <div align="center">CustomerID </div></th>
<th width="98"> <div align="center">Name </div></th>
<th width="198"> <div align="center">Language </div></th>
<th width="97"> <div align="center">Advisor </div></th>
<th width="97"> <div align="center">Proj </div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$objResult["ID"];?></div></td>
<td><?=$objResult["Name"];?></td>
<td><?=$objResult["Language"];?></td>
<td><div align="center"><?=$objResult["Advisor"];?></div></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]&Lang=$_GET[Lang]&Adv=$_GET[Adv]'><< Back</a>";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_GET[txtKeyword]&Lang=$_GET[Lang]&Adv=$_GET[Adv]'>$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_GET[txtKeyword]&Lang=$_GET[Lang]&Adv=$_GET[Adv]'>Next>></a> ";
}
mysql_close($objConnect);
}
?>
|
|
|
|
|
Date :
2013-06-21 16:01:20 |
By :
mrronalz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|