"0") $categories = catree($row[cat]); $categories .= "$fwasel$row[name]"; } mysqli_free_result($query); return $categories; } function catree2($id){ global $connect; $query = mysqli_query($connect,"SELECT id,cat,name FROM cat where cat=$id "); while($row = mysqli_fetch_array($query)){ $categories .= catree2($row[id])." or act like '%|$row[id]|%'"; } mysqli_free_result($query); return $categories; } if($c=="0") $c=""; if($b=="0") $b=""; if($c != "" and $c != "0"){ //////////// الاعلانات /////////////// $queryhads = mysqli_query($connect,"SELECT ad FROM ads where type = '1' and cat = '$c' order by id ASC"); while($rowhads = mysqli_fetch_array($queryhads)) $headerads .= $rowhads[ad]; mysqli_free_result($queryhads); $querymads = mysqli_query($connect,"SELECT ad FROM ads where type = '2' and cat = '$c' order by id ASC"); while($rowmads = mysqli_fetch_array($querymads)) $mainads .= $rowmads[ad]; mysqli_free_result($querymads); $queryfads = mysqli_query($connect,"SELECT ad FROM ads where type = '3' and cat = '$c' order by id ASC"); while($rowfads = mysqli_fetch_array($queryfads)) $footerads .= $rowfads[ad]; mysqli_free_result($queryfads); //////////// نهاية الاعلانات /////////////// } if($w == "كلمة البحث ..") $w = ""; $qucat = ""; if($c != "") $qucat = "where act like '%|$c|%'"; if($b != ""){ if($qucat == "") $qucat = "where block like '%|$b|%'"; else $qucat .= "and block like '%|$b|%'"; } if($w != ""){ $qusearch = ""; $wordex = explode(" ",$w); for ($i = 0; $i < count($wordex); $i++){ if ($wordex[$i] != "" and strlen($wordex[$i]) > 2){ $qusearch .= " or title like ('% $wordex[$i] %') or title like ('$wordex[$i] %') or title like ('% $wordex[$i]')"; } } if($qucat == "") $qucat = "where (title like ('%$w%')$qusearch)"; else $qucat .= "and (title like ('%$w%')$qusearch)"; } if($qucat == "") $qucat = "where"; else $qucat .= " and"; if ($npage == "" or $npage == "0"){ $npage = 1; }else{ $npage = $npage; } if($npage == "1"){ if($w != ""){ $queryw = mysqli_query($connect,"SELECT * FROM word where word = '$w'"); $numw = mysqli_num_rows($queryw); mysqli_free_result($queryw); if($numw == "0") mysqli_query($connect,"INSERT INTO word(word,t) VALUES ('".$w."',1) "); else mysqli_query($connect,"UPDATE word set t = t + 1 where word = '". $w ."' "); } } if($sp == "1"){ if($c != "" and $c != "0"){ $query1 = mysqli_query($connect,"SELECT * FROM cat where id = '$c'"); while($row1 = mysqli_fetch_array($query1)) $namesp1 = "$row1[name]"; mysqli_free_result($query1); } if($namesp1 != "") $namespok = "$namesp1 في $w"; } $qucat = str_replace(" like "," like binary ",$qucat); $oksure = "(title like '%$w%')"; if($_GET[area]=="1"){ $oksure = "email = '$w'"; if($c != "" and $c != "0") $oksure .= " and (act like '%|$c|%' ".catree2($c)." )"; } $frommaxinpage=($thingsinpage*$npage)-$thingsinpage; $w = mysqli_real_escape_string($connect, $w); $w_like = str_replace(' ', '%', $w); $querytoshowsites = mysqli_query($connect," SELECT id, title, pic, rtime, branch, MATCH(title) AGAINST('".$w."' IN NATURAL LANGUAGE MODE) AS score FROM thing WHERE ok = 1 AND ( MATCH(title) AGAINST('".$w."' IN NATURAL LANGUAGE MODE) OR title LIKE '%".$w_like."%' ) ORDER BY score DESC, time DESC LIMIT ".$frommaxinpage.",".$thingsinpage." "); //$querytoshowsites = mysqli_query($connect,"SELECT * FROM thing where (title LIKE '".$w."%' or title LIKE '% ".$w."%') and ok = 1 order by time DESC limit ".$frommaxinpage.",".$thingsinpage); //$querytoshowsites = mysqli_query($connect,"SELECT * FROM thing where $oksure and ok = 1 order by time DESC limit ".$frommaxinpage.",".$thingsinpage); $numthisth = 0; while($row3 = mysqli_fetch_array($querytoshowsites)){ $numthisth ++; $things[] = array("id"=>$row3[id],"title"=>$row3[title],"pic"=>spic($row3[pic]),"date"=>td($row3[rtime],1,$limittimeshow),"price"=>$row3[branch]); } mysqli_free_result($querytoshowsites); mysqli_free_result($querytonumsites); if($numthisth == $thingsinpage) $morepage = "الصفحة التالية "; if($npage != 1 or $morepage != ""){ $morepages = 1; if($npage != 1) $ppage = "الصفحة السابقة "; } $tkmlhnamesite = ""; if($npage > "1") $tkmlhnamesite = " - الصفحة $npage"; if($sp == "1" and $namespok != ""){ $namesite = $namespok.$tkmlhnamesite; }else{ $namesite = "بحث".$tkmlhnamesite; if($w != "") $namesite = $w.$tkmlhnamesite; } $np = "$ornamesite$fwasel$w"; echo $tpl->display($ftemplets,"header.html"); echo $tpl->display($ftemplets,"menur.html"); echo $tpl->display($ftemplets,"cat.html"); echo $tpl->display($ftemplets,"menul.html"); echo $tpl->display($ftemplets,"footer.html"); mysqli_close ($connect); ?>