PHP’de Veritabanında Arama Yapmak İçin

<?php
$kelime=trim($_GET[kelime]);
$kelime=strip_tags($kelime);

$bol=explode("+",$kelime);
$say=count($bol);

if ($say>1) {
$sorgu=mysql_query("select field from tablo where (field LIKE '%".$kelime."%' or field LIKE '%".$bol[1]."%' or field LIKE '%".$bol[2]."%') order by field limit 10");
} else if ($say>2) {
$sorgu=mysql_query("select field from tablo where (field LIKE '%".$kelime."%' or field LIKE '%".$bol[1]."%' or field LIKE '%".$bol[2]."%' or field LIKE '%".$bol[3]."%') order by field limit 10");
} else if ($say>3) {
$sorgu=mysql_query("select field from tablo where (field LIKE '%".$kelime."%' or field LIKE '%".$bol[1]."%' or field LIKE '%".$bol[2]."%' or field LIKE '%".$bol[3]."%' or field LIKE '%".$bol[4]."%') order by field limit 10");
} else {
$sorgu=mysql_query("select field from tablo where field LIKE '%".$kelime."%' order by field limit 10");
}
while ($oku=mysql_fetch_array($sorgu) {
echo $oku[field]."<br />";
} 
?>

Be the first to comment

Leave a Reply

Your email address will not be published.


*