MacroOnline Browser |
![]() |
||||||||
|
//The following code display the search form
if ($source==''){
?>
}
/**
The following code displays the search results
first the values from the search form are being edited, then a sql query is being build.
*/
if ($source=='result'){
$show_all=@$_SESSION['showall'];
if ($show_all=='false'){
$keyword=@$_SESSION['keyword'];
$searchtype=@$_SESSION['searchtype'];
$datatype=@$_SESSION['datatype'];
if (@$_SESSION['country']){
foreach ($_SESSION['country'] as $value){
$country=$_SESSION['country'];
}
$country=preg_replace("/( +)/", " ", $country);
}
if ($keyword){
@$keyword=preg_replace("/( +)/", " ", $keyword);
@$keyarray=explode(" ",$keyword);
@$arr_length = count($keyarray);
@$value=$arr_length-1;
if ($arr_length>1){
$condition=" ((";
for($i=0;$i<$arr_length-1;$i++){
$condition=$condition . "name like '%$keyarray[$i]%' $searchtype ";
}
$condition=$condition . "name like '%$keyarray[$value]%') OR (";
for($i=0;$i<$arr_length-1;$i++){
$condition=$condition . "content like '%$keyarray[$i]%' $searchtype ";
}
$condition=$condition . " content like '%$keyarray[$value]%'))";
}
else $condition="(name like '%$keyword%' OR content like '%$keyword%')";
}
if ($datatype){
if (@$condition) {$condition=$condition . " AND type='$datatype'";}
else $condition= "type='$datatype'";
}
}
if (@$country){
if (@$condition){$condition=$condition . " AND ("; }
else $condition="(";
$arr_country_length = count($country);
$counter=$arr_country_length;
if ($arr_country_length==1){
$condition=$condition . "country like '%$country[0]%'";
} else {
foreach ($country as $value){
$condition=$condition . "country like '%$value%'";
if ($counter>=2){$condition=$condition . " OR ";
$counter=$counter - 1;
}
}
}
$condition=$condition . ")";
}
if (@$condition){
$sql_search="SELECT * FROM main WHERE $condition";
}
else $sql_search="SELECT * FROM main";
if ($show_all=='true'){
$sql_search="SELECT * FROM main";
}
$result = mysql_query ($sql_search,$macrocon);
$num_of_rows = mysql_num_rows ($result);
if ($num_of_rows){
?>
Your search returned # echo ($num_of_rows . ' ') ?> results. (New Search / alter search)
New Search / alter search } } /** mysql_free_result($result); mysql_close($macrocon); */ ?> |
//loading the navigation menu include("menu.inc"); ?> |