• 19-09-2010, 16:20:15
    #1
    Merhabalar, veritabanımda gerekli indexleri oluşturdum aşağıdaki kodda like yerine full text search ile arama yapmak istiyorum

    // Display games
    function searchgames($page,$searchTerm) {
        global $siteurl, $filesperpage, $sefriendly, $resimler;
        $result = mysql_query("SELECT * FROM files WHERE title LIKE '%$searchTerm%' && status ='1' || description LIKE '%$searchTerm%' && status ='1'");
     
    if(empty($searchTerm)) {
    echo "Site adi";
    } else {
    echo $searchTerm;
    }
    yardımcı olanlara şimdiden teşekkurler.
  • 19-09-2010, 16:59:04
    #2
    Ravenger adlı üyeden alıntı: mesajı görüntüle
    Bu İş Tarafımızca Yapıma Aılınmıştır
    henüz alınan bişey yok ortada diğer arkadaşların yardımlarını bekliyorum.
  • 19-09-2010, 18:15:10
    #3
    function searchgames($page,$searchTerm) {
        global $siteurl, $filesperpage, $sefriendly, $resimler;
        $result = mysql_query("SELECT * FROM files WHERE match(title, description)against('$searchTerm') && status ='1'");
     
    if(empty($searchTerm)) {
    echo "Site adi";
    } else {
    echo $searchTerm;
    }
    Not: Title ve Description alanlarının ikisini birden seçip full text search olarak belirtmeniz gerekiyor. Bu işlemi yaptıkdan sonra tabloyu onarmanız gerekmektedir.
    Not2: SearchTerm değişkenini get motodu ile gönderirseniz UTF-8 olarak kodlayacağından dolayı arama işlemi Türkçe karakterlerde gerçekleşmeyecektir. Bunun için fonksiyona değişkeni vermeden önce şunu kullanmanız gerekmektedir "$searchTerm = iconv('UTF-8', 'ISO-8859-9', $searchTerm);". Bu işlemi tablolar utf-8 olarak belirtilmiş ise bu işlemi yapmaya gerek yoktur.
  • 19-09-2010, 19:00:52
    #4
    mustafa90 adlı üyeden alıntı: mesajı görüntüle
    function searchgames($page,$searchTerm) {
        global $siteurl, $filesperpage, $sefriendly, $resimler;
        $result = mysql_query("SELECT * FROM files WHERE match(title, description)against('$searchTerm') && status ='1'");
     
    if(empty($searchTerm)) {
    echo "Site adi";
    } else {
    echo $searchTerm;
    }
    Not: Title ve Description alanlarının ikisini birden seçip full text search olarak belirtmeniz gerekiyor. Bu işlemi yaptıkdan sonra tabloyu onarmanız gerekmektedir.
    Not2: SearchTerm değişkenini get motodu ile gönderirseniz UTF-8 olarak kodlayacağından dolayı arama işlemi Türkçe karakterlerde gerçekleşmeyecektir. Bunun için fonksiyona değişkeni vermeden önce şunu kullanmanız gerekmektedir "$searchTerm = iconv('UTF-8', 'ISO-8859-9', $searchTerm);". Bu işlemi tablolar utf-8 olarak belirtilmiş ise bu işlemi yapmaya gerek yoktur.
    merhaba title ve Description kısımlarında full text searci sectim ve tabloları onardım başka bişewy yapmaya gerek varmı ?
  • 19-09-2010, 19:21:50
    #5
    birde sizin kodunuzdan sonra şöyle bir hata alıyorum sonraki satırlarda
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/siteismi/public_html/includes/kraloyun.php on line 13

    kod:
    function searchgames($page,$searchTerm) {
        global $siteurl, $filesperpage, $sefriendly, $resimler;
        $result = mysql_query("SELECT * FROM files WHERE match(title, description)against('$searchTerm') && status ='1'");
     
    if(empty($searchTerm)) {
    echo "Site adi";
    } else {
    echo $searchTerm;
    }
     
        if (mysql_num_rows($result) == '0') {
            echo " etiketindeki oyunlar gösteriliyor.";
    
        $result2 = mysql_query("SELECT * FROM files order by rand() desc limit 22");
        
            $fileinrow="1";
        while($row = mysql_fetch_array($result2)) {
            $fileid = $row['fileid'];
            $filetitle = $row['title'];
            $filerating = $row['rating'];
            $filedescription = $row['description']." oyunları, ".$row['description']." flash oyunları, ".$row['description']." kral oyun, ".$row['description']." oyunlar oyna,";
            $fileicon = $row['icon'];
            $iconlocation = $row['iconlocation'];
            $timesplayed = number_format($row['timesplayed']);
            
            if ($iconlocation == '1') {
                $imageurl = $resimler.$fileicon;
            } else {
                $imageurl = $fileicon;
            }
            
            if (strlen($filedescription) > '40') {
                $filedescription = substr("$filedescription",0,37)."...";
            }
    not: yardımcı olacak arkadaşın aklının karışmaması için üstteki kod ile hata veren kodu birleştirip verdim.
  • 19-09-2010, 19:51:56
    #6
    "echo mysql_error();" yazıp hata mesajına bakarmısın. Bu verdiğim kodu hata veren satırın altına koyarsın.

    Not: Tekrar söyliyeyim. Tablo alanlarını teker teker "full text search" olarak işaretlemiyeceksin. İlgili alanları checkbox ile seçerek alttaki iconlardan "full text search" olanına basacaksın
  • 20-09-2010, 02:44:50
    #7
    merhaba php ve full text search hatalarını hallettim suan arama calışıyor ama bazı 3-4 sonuclu aramalarda sayfa numaraları cıkıyor, mesela bazı aramalarda sonuc cıkmaz ise yerine 25 rastgele oyun basıyorum bazı aramalarda bu rastgele 25 oyun bazen gelmiyor yardımcı olabilirseniz sevinirim.

    http://www.zenoyun.com/Oyunlari/scooby-sayi-oyunu
    mesela bunda hiç sonuc yok sayfa numaraları var
    sonuc olmadığı zaman rastgele 25 oyun dönmesi gerekiyor ama yok

    mesela bu arama sonucu normal
    http://www.zenoyun.com/Oyunlari/raccoon-yarislari

    burdada normal olarak sonucu olmayan arama için 25 rastgele sonuc döndürüyor
    http://www.zenoyun.com/Oyunlari/limunes

    kısacası sapıttı script

    Search.php kodları:
    Alıntı
    <?php

    // Display games
    function searchgames($page,$searchTerm) {
    global $siteurl, $filesperpage, $sefriendly, $resimler;
    $result = mysql_query("SELECT * FROM files WHERE match(title, description)against('$searchTerm') && status ='1'");

    if(empty($searchTerm)) {
    echo "Site adi";
    } else {
    echo $searchTerm;
    }

    if (mysql_num_rows($result) == '0') {
    echo " kelimesi geçen oyunlar listeleniyor.";



    $result2 = mysql_query("SELECT * FROM files order by rand() desc limit 22");

    $fileinrow="1";
    while($row = mysql_fetch_array($result2)) {
    $fileid = $row['fileid'];
    $filetitle = $row['title'];
    $filerating = $row['rating'];
    $filedescription = $row['description']." oyunları, ".$row['description']." flash oyunları, ".$row['description']." kral oyun, ".$row['description']." oyunlar oyna,";
    $fileicon = $row['icon'];
    $iconlocation = $row['iconlocation'];
    $timesplayed = number_format($row['timesplayed']);

    if ($iconlocation == '1') {
    $imageurl = $resimler.$fileicon;
    } else {
    $imageurl = $fileicon;
    }

    if (strlen($filedescription) > '40') {
    $filedescription = substr("$filedescription",0,37)."...";
    }

    if ($fileinrow == '1') {
    echo "<tr>";
    }
    $fileinrow="1";
    while($row = mysql_fetch_array($result2)) {
    $fileid = $row['fileid'];
    $filetitle = $row['title'];
    $filedescription = $row['description']." oyna, ".$row['description']." flash oyunları, ".$row['description']." kral oyun, ".$row['description']." oyna,";
    $fileicon = $row['icon'];
    $iconlocation = $row['iconlocation'];
    $timesplayed = number_format($row['timesplayed']);

    if ($iconlocation == '1') {
    $imageurl = $resimler.$fileicon;
    } else {
    $imageurl = $fileicon;
    }

    if (strlen($filedescription) > '40') {
    $filedescription = substr("$filedescription",0,37)."...";
    }

    if ($fileinrow == '1') {
    echo "<tr>";
    }
    ?>
    <td width="33%">
    <table class="browsegamesbox">
    <tr>
    <td width="71" valign="top">
    <a href="<?php echo fileurl($fileid,$filetitle); ?>" target="_self"><img src="<?php echo $imageurl; ?>" title="<?php echo $filetitle; ?> oyna" width="70" height="59" ALT="<?php echo $filetitle; ?>" border="0"></a>
    </td>
    <td valign="top">
    <a title="<?php echo $filetitle; ?> oyunu" href="<?php echo fileurl($fileid,$filetitle); ?>" target="_self" class="gamelink"><?php echo $filetitle; ?></a><br />
    <?php echo $filedescription; ?><br />
    <span class="Toplam-oynanan-oyun">(Oynanma: <?php echo $timesplayed; ?> Kez)</span>
    <img src="<?php echo $siteurl; ?>/images/stars<?php echo $filerating; ?>.gif" border="0" width="60" height="10" alt="<?php echo $filerating; ?>" title="<?php echo $filerating; ?>">
    </td>
    </tr>
    </table>
    <?php
    if ($fileinrow == '3') {
    echo "</tr>";
    $fileinrow = "0";
    }
    $fileinrow++;
    }
    if ($fileinrow == '2') {
    echo "<td width=\"33%\"></td><td width=\"33%\"></td></tr>";
    } elseif ($fileinrow == '3') {
    echo "<td width=\"33%\"></td></tr>";
    }}







    } else {


    // Get number of pages
    $numrows = mysql_num_rows($result);
    $offset = ($page - 1) * $filesperpage;
    $pagescount = ceil($numrows/$filesperpage);

    for ($pagen = 1; $pagen <= $pagescount; $pagen++) {
    if ($pagen == $page) {
    $nav .= "&nbsp;<b>$pagen</b>";
    } else {
    $nav .= "&nbsp;<a href=\"".$siteurl."/index.php?action=search&t=".$searchTerm."&page=".$ pagen."\">$pagen</a>";
    }
    }
    if ($page > 1) {
    $pagen = $page - 1;
    $prev = "<a href=\"".$siteurl."/index.php?action=search&t=".$searchTerm."&page=".$ pagen."\">< Previous</a>";
    } else {
    $prev = "";
    }
    if ($page < $pagescount) {
    $pagen = $page + 1;
    $next = "&nbsp;<a href=\"".$siteurl."/index.php?action=search&t=".$searchTerm."&page=".$ pagen."\">Next ></a>";
    } else {
    $next = "";
    }
    // Display page numbers
    if ($pagescount > '1') {
    echo "<tr><td colspan='3' class='pagenumbers'>".$prev.$nav.$next."</td></tr>";
    }

    $result2 = mysql_query("SELECT title, icon, iconlocation, fileid, description, rating, timesplayed FROM files WHERE title LIKE '%$searchTerm%' && status ='1' || description LIKE '%$searchTerm%' && status ='1' ORDER BY title LIMIT $offset, $filesperpage");

    $fileinrow="1";
    while($row = mysql_fetch_array($result2)) {
    $fileid = $row['fileid'];
    $filetitle = $row['title'];
    $filerating = $row['rating'];
    $filedescription = $row['description'];
    $fileicon = $row['icon'];
    $iconlocation = $row['iconlocation'];
    $timesplayed = number_format($row['timesplayed']);

    if ($iconlocation == '1') {
    $imageurl = $resimler.$fileicon;
    } else {
    $imageurl = $fileicon;
    }

    if (strlen($filedescription) > '40') {
    $filedescription = substr("$filedescription",0,37)."...";
    }

    if ($fileinrow == '1') {
    echo "<tr>";
    }
    ?>
    <td width="33%">
    <table class="browsegamesbox">
    <tr>
    <td width="71" valign="top">
    <a href="<?php echo fileurl($fileid,$filetitle); ?>" target="_self"><img src="<?php echo $imageurl; ?>" width="70" height="59" title="<?php echo $filetitle; ?>" border="0"></a>
    </td>
    <td valign="top">
    <a href="<?php echo fileurl($fileid,$filetitle); ?>" target="_self" class="gamelink"><?php echo $filetitle; ?></a><br />
    <?php echo $filedescription; ?><br />
    <span class="Toplam-oynanan-oyun">(Oynanma: <?php echo $timesplayed; ?> Kez)</span>
    <img src="<?php echo $siteurl; ?>/images/stars<?php echo $filerating; ?>.gif" border="0" width="60" height="10" alt="<?php echo $filerating; ?>" title="<?php echo $filerating; ?>">
    </td>
    </tr>
    </table>
    <?php
    if ($fileinrow == '3') {
    echo "</tr>";
    $fileinrow = "0";
    }
    $fileinrow++;
    }
    if ($fileinrow == '2') {
    echo "<td width=\"33%\"></td><td width=\"33%\"></td></tr>";
    } elseif ($fileinrow == '3') {
    echo "<td width=\"33%\"></td></tr>";
    }
    // Display page numbers
    if ($pagescount > '1') {
    echo "<tr><td colspan='3' class='pagenumbers'>".$prev.$nav.$next."</td></tr>";
    }
    }
    }
    ?>