//global $Search;
$ID="";
$data = array();
$data["conteinerData"]="";
$d = (int)$_POST['d'];
$category = mysql_real_escape_string($_POST['cat']);
$gender = isset($_POST['gender'])?mysql_real_escape_string($_POST['gender']):null;
$category = $category=="Category"?"":$category;
$gender = $gender=="noGender"?"":$gender;
$minPrice = (float)$_POST['minPrice'];
$maxPrice = (float)$_POST['maxPrice'];
$selectSearchDD_emails_edu = !empty($_POST['selectSearchDD_emails_edu'])?_f::getAntiXSS($_POST['selectSearchDD_emails_edu']):""; // поиск по мыльному домену @..edu
$selectSearchDD_emails = !empty($_POST['selectSearchDD_emails'])?_f::getAntiXSS($_POST['selectSearchDD_emails']):""; // поиск по мыльному домену
$Search = !empty($_POST['Search'])?_f::getAntiXSS($_POST['Search']):"";
$lat = (FLOAT)$_POST['lat'];
$lon = (FLOAT)$_POST['lon'];
$corStr=(int)$_POST['cor_str'];
$limit_from = $corStr*$limit-$limit;
$search = ""; // общий поиск по сайту
$location = "1=1"; // локация и удаление
$TG="";
if ($category!="")
{
$genderW = !empty($gender)? " gender='"._f::getAntiXSS($gender)."' ": " gender != 'null' ";
$type = " type='"._f::getAntiXSS($category)."' ";
$TG = "( {$type} AND {$genderW} )";
}
if (!empty($selectSearchDD_emails_edu))
{
$email = " email LIKE ('%{$selectSearchDD_emails_edu}%') ";
}
else
{
if(!empty($selectSearchDD_emails))
{
if ($selectSearchDD_emails=="other")
{
$email = " ( email NOT LIKE ('%.com%') AND email NOT LIKE ('%.edu%') ) ";
}else $email = " email LIKE ('%{$selectSearchDD_emails}%') ";
}
}
if (!empty($Search))
{
$arrWHEREs = array
(
" name LIKE ('%{$Search}%')",
" address LIKE ('%{$Search}%')",
" description LIKE ('%{$Search}%')",
" link LIKE ('%{$Search}%')",
" vlink LIKE ('%{$Search}%')",
" email LIKE ('%{$Search}%')",
" type LIKE ('%{$Search}%')",
" age LIKE ('%{$Search}%')",
" gender LIKE ('%{$Search}%')",
" price LIKE ('%{$Search}%')",
" date LIKE ('%{$Search}%')",
);
$search = " ( ".implode(" or ", $arrWHEREs)." ) ";
} else $search ="";
$arrWHERE = array();
if (!empty($TG)) $arrWHERE[]=$TG;
if (!empty($email)) $arrWHERE[]=$email;
$search2 = implode(" and ", $arrWHERE);
$AND = empty($search2) || empty($search) ?" ":" AND ";
$search = trim($search.$AND.$search2);
if (empty($search)) $search="1=1";
if (!empty($lat))
{
$location = "( ( ACOS( SIN( {$lat} * PI() / 180) * SIN(lat * PI() / 180) + COS( {$lat} * PI() / 180) * COS(lat * PI() / 180) * COS(({$lon} - lng) * PI() / 180) ) * 180 / PI()) * 60 * 1.1515)<=$d";
}
$qr = "SELECT * FROM markers WHERE ( ( {$location} ) AND ( {$search} ) AND price BETWEEN {$minPrice} AND {$maxPrice} ) AND varifMail='Ok' ORDER BY `date` DESC ";
$data["qr"]= IS_DEBUG===TRUE?$qr:"is debug off";
$_SESSION['query']=$qr;
$result = $bd->query($qr." LIMIT $limit_from, $limit ");
$data["kolVo"]=0;
// Creates an array of strings to hold the lines of the KML file.
setKML();
$kol_td = 1;
$resForData = $result;
if (!empty($isMobile))
{
//echo "Search result file kml";
$d = _t::contentAddsMobile($resForData);
}else
{
//echo "Search result file kml";
$d = _t::contentAddsDesctop($resForData);
}
$data['content']=array();
$data['content']=$d['content'][0];
for ($j=0; $j<count($d['row']); $j++){
$row = $d['row'][$j];
$data["kolVo"]++;
addKML($row["id"],$row["name"],$row["address"],$row["description"],$row["link"],$row["vlink"],$row["email"],$row["pic"],$row["type"],$row['gender'],$row["lng"],$row["lat"]);
$data["markers"]["lng"][]=$row["lng"];
$data["markers"]["lat"][]=$row["lat"];
}
Это наверное в этой части кода формируется поиск?
if (!empty($TG)) $arrWHERE[]=$TG;
if (!empty($email)) $arrWHERE[]=$email;
$search2 = implode(" and ", $arrWHERE);
$AND = empty($search2) || empty($search) ?" ":" AND ";
$search = trim($search.$AND.$search2);
if (empty($search)) $search="1=1";
Я просто пока еще не силен в программировании. Потому возможно мои вопросы довольно глупы.
По моему решил, and и AND на or и OR поменял. Огромное спасибо форуму. Эффект генерала в полной мере доказан еще раз.