• 05-04-2008, 12:14:08
    #1
    Alttaki kod datetime göre çağırıyor. terms kolonunda aynı kayıtlar var sayfada aynı kayıtlar tekrarlanıp çıkıyor. Tekrarlanmadan çıkması icin ne yapılması gerek.
    tablo adı : wp_searchmeter_recent
    kolon adları : terms , datatime , hits , details

    function sm_list_recent_searches($before = '', $after = '', $count = 20) {
    // List the most recent successful searches.
    	global $wpdb, $table_prefix;
    	$count = intval($count);
    	$results = $wpdb->get_results(
    		"SELECT `terms`, `datetime`
    		FROM `{$table_prefix}searchmeter_recent`
    		WHERE 0 < `hits`
    		ORDER BY `datetime` DESC
    		LIMIT $count");
    	if (count($results)) {
    		echo "$before\n<p>\n";
    		foreach ($results as $result) {
    			echo '<a href="'. get_settings('home') . '/search/' . urlencode($result->terms) . '">'. htmlspecialchars($result->terms) .'</a>, '."\n";
    		}
    		echo "</p>\n$after\n";
    	}
    }
  • 05-04-2008, 16:33:04
    #2
    function sm_list_recent_searches($before = '', $after = '', $count = 20) {
    // List the most recent successful searches.
        $aqqq = array('132');
        global $wpdb, $table_prefix;
        $count = intval($count);
        $results = $wpdb->get_results(
            "SELECT `terms`, `datetime`
            FROM `{$table_prefix}searchmeter_recent`
            WHERE 0 < `hits`
            ORDER BY `datetime` DESC
            LIMIT $count");
        if (count($results)) {
            echo "$before\n<p>\n";
            foreach ($results as $result) {
                if (!in_array($result,$aqqq)) {
                array_push($aqqq, "$result");
                echo '<a href="'. get_settings('home') . '/search/' . urlencode($result->terms) . '">'. htmlspecialchars($result->terms) .'</a>, '."\n";
               }
            }
            echo "</p>\n$after\n";
        }
    }
    böyle denermisin. bir array yarattik. echo edilirken array da o term warmi baktik. yoksa bastik echo ve array a ekledik.
  • 05-04-2008, 16:40:01
    #3
    Yani kısaca terms de gelen verilerin aynıları temeda tekrarlamayacak mı?
    Edit: olmadı
  • 05-04-2008, 17:06:26
    #4
    hata mi verdi yoksa ayni termleri göstermeye devammi ediyor ?
  • 05-04-2008, 17:36:36
    #5
    Üyeliği durduruldu
    ORDER BY `datetime` DESC bundan önce GROUP BY terms kullanabilirsin.
  • 06-04-2008, 20:32:34
    #6
    LaCReMeL adlı üyeden alıntı: mesajı görüntüle
    hata mi verdi yoksa ayni termleri göstermeye devammi ediyor ?
    Aynı devam ediyor göstermeye bir değişiklik olmadı yani
  • 06-04-2008, 21:16:10
    #7
    function sm_list_recent_searches($before = '', $after = '', $count = 20) {
    // List the most recent successful searches.
        $aqqq = array('132');
        global $wpdb, $table_prefix;
        $count = intval($count);
        $results = $wpdb->get_results(
            "SELECT `terms`, `datetime`
            FROM `{$table_prefix}searchmeter_recent`
            WHERE 0 < `hits`
            ORDER BY `datetime` DESC
            LIMIT $count");
        if (count($results)) {
            echo "$before\n<p>\n";
            foreach ($results as $result) {
                if (!in_array($result->terms,$aqqq)) {
                array_push($aqqq, "$result->terms");
                echo '<a href="'. get_settings('home') . '/search/' . urlencode($result->terms) . '">'. htmlspecialchars($result->terms) .'</a>, '."\n";
               }
            }
            echo "</p>\n$after\n";
        }
    }
    böyle denermisin ?
  • 06-04-2008, 22:02:04
    #8
    çok saol oldu sanırım şimdi. Aslında bide search meter aynı aramayı sürekli kaydetip duruyor nedendir bilmem boşuna db şişirmekden başka anlamı yok. Onun nedenlerinden birisi bu yeni eklenenleri düzeltmek istedimde. O kaydetmeyi nasıl düzeltiriz?