$strSQL = "SELECT * FROM Member WHERE (IDCard LIKE '%".$_GET["txtKeyword"]."%' and Sex LIKE '%".$_GET["txtKeyword2"]."%' and District LIKE '%".$_GET["txtKeyword3"]."%'and Education LIKE '%".$_GET["txtKeyword4"]."%'and Income LIKE '%".$_GET["txtKeyword5"]."%' ) ";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mssql_num_rows($objQuery);
Code (PHP)
<html>
<head>
<title>................<<..>>.............</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874"></head>
<body>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="599" border="1">
<tr>
<th><p>
ID
<input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>">
<br>
Se
<input name="txtKeyword2" type="text" id="txtKeyword2" value="<?=$_GET["txtKeyword2"];?>">
<br>
Di
<input name="txtKeyword3" type="text" id="txtKeyword3" value="<?=$_GET["txtKeyword3"];?>">
<br>
Ed
<input name="txtKeyword4" type="text" id="txtKeyword4" value="<?=$_GET["txtKeyword4"];?>">
<br>
In
<input name="txtKeyword5" type="text" id="txtKeyword5" value="<?=$_GET["txtKeyword5"];?>">
<br>
<input type="submit" value="Search">
</p></th>
</tr>
</table>
</form>
<?
include("../config.inc.php") ;
// Search By Name or Email
$strSQL = "SELECT * FROM Member WHERE (IDCard LIKE '%".$_GET["txtKeyword"]."%' and Sex LIKE '%".$_GET["txtKeyword2"]."%' and District LIKE '%".$_GET["txtKeyword3"]."%'and Education LIKE '%".$_GET["txtKeyword4"]."%'and Income LIKE '%".$_GET["txtKeyword5"]."%' ) ";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mssql_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;
}
$Page_End = $Per_Page * $Page;
IF ($Page_End > $Num_Rows)
{
$Page_End = $Num_Rows;
}
?>
<table width="1021" border="1">
<tr>
<th width="91"> <div align="center">IDCard</div></th>
<th width="203"> <div align="center">FName</div></th>
<th width="131">Sex</th>
<th width="218">District</th>
<th width="182">Education</th>
<th width="156"> <div align="center">InCome</div></th>
</tr>
<?
for($i=$Page_Start;$i<$Page_End;$i++)
{
?>
<tr>
<td><div align="center"><?=mssql_result($objQuery,$i,"IDCard");?></div></td>
<td><?=mssql_result($objQuery,$i,"FName");?></td>
<td><?=mssql_result($objQuery,$i,"Sex");
?></td>
<td><?=mssql_result($objQuery,$i,"District");
?></td>
<td><?=mssql_result($objQuery,$i,"Education");
?></td>
<td><?=mssql_result($objQuery,$i,"Income");
?></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> ";
}
mssql_close($objConnect);
?>
</body>
</html>