How to multiple search by the one word
<?php
if ( $_POST["funSearch"] != "" )
{
$cond='';
if ( $_POST["name"] != "" )
{
$cond .=" and firstname like '%". $_POST["name"] ."%' " ;
$_SESSION["nam"]=$_POST["name"];
}
else
{
$_SESSION["nam"]="";
}
if ( $_POST["mobile"] != "" )
{
$cond .=" and mobile1 like '%". $_POST["mobile"] ."%' " ;
$_SESSION["mob"]=$_POST["mobile"];
}
else
{
$_SESSION["mob"]="";
}
if ( $_POST["address"] != "" )
{
$cond .= " and address1 like '%". $_POST["address"] ."%' ";
$_SESSION["add"]= $_POST["address"];
}
else
{
$_SESSION["add"]="";
}
if ( $_POST["city"] != "" )
{
$cond .=" and city like '%". $_POST["city"] ."%' " ;
$_SESSION["cit"]=$_POST["city"];
}
else
{
$_SESSION["cit"]="";
}
if ( $_POST["state"] != "" )
{
$cond .=" and state like '%". $_POST["state"] ."%' " ;
$_SESSION["sta"]=$_POST["state"];
}
else
{
$_SESSION["sta"]="";
}
if ( $_POST["email"] != "" )
{
$cond .=" and email1 like '%". $_POST["email"] ."%' " ;
$_SESSION["ema"]=$_POST["email"];
}
else
{
$_SESSION["ema"]="";
}
$searchquery="SELECT * FROM `contact` where firstname <> '' " ;
if ( $cond != "" )
{
$searchquery=$searchquery . $cond ;
}
// $searchquery1=$searchquery . " ORDER BY ID desc LIMIT $StartRow,$PageSize ";
// $searchquery=$searchquery . " ORDER BY ID desc ";
//echo $searchquery;
//$TRecord = mysql_query($searchquery);
$result = mysql_query($searchquery);
}
else
{
$result = mysql_query("SELECT * FROM `contact` where cat_id ='0'");
}
//Total of record
// $RecordCount = mysql_num_rows($TRecord);
//Set Maximum Page
// $MaxPage = $RecordCount % $PageSize;
//// if($RecordCount % $PageSize == 0){
// $MaxPage = $RecordCount / $PageSize;
// }else{
// $MaxPage = ceil($RecordCount / $PageSize);
// }
?>
----------------------call this by on click search---------------------------------------------
<input type="hidden" name="funSearch" value="1">
<input type="submit" name="Search" value="Search" />
Comments
Post a Comment