النتائج 1 إلى 3 من 3

الموضوع: طلب مساعدة في كيفية استخراج نتائج البحث

  1. #1
    عضو جديد
    تاريخ التسجيل
    Dec 2008
    المشاركات
    3

    طلب مساعدة في كيفية استخراج نتائج البحث



    السلام عليكم ورحمة الله وبركاته
    عندي جدول أخبار في قاعدة البيانات للأخبار ويحتوي على حقول
    منها title
    news_head
    post

    title عنوان الخبر
    news_head راس الخبر
    post تكملة الخبر

    عملت لهؤلاء الحقول ميزة fulltext من قاعدة البينات لكي استخدم خاصية البحث

    ونتيجة البحث تخرج بشكل سليم حيث تخرج عناوين الأخبار التي تحمل الكلمة المبحوث عنها
    ولكن انا لا اريد عناوين الأخبار بل اريد النتائج تكون من نفس الخبر (post)

    اي يعرض لي الخبر وبه الكلمة المبحوث عنها مثل قوقل بالضبط

    طبعا انا جعلت ناتج البحث من الخبر نفسه لكن يعرض لي كامل الخبر
    انا اريد فقط مختصر للخبر الذي يحمل الكلمة مثل قوقل بالضبط

    مرفق صورة للمطلوب





    الصور المرفقة الصور المرفقة  


  2. #2
    عضو سوبر نشيط
    تاريخ التسجيل
    May 2007
    المشاركات
    947


    أولاً لقد أحسنت الإختيار لاستعمال ال full text search
    لكن يتطلب تنقية الكلمات والموضوعات من وسوم html حتى يكون دقيق
    اما عن فكرة عرض موجز عن البحث فيمكن عملها عن طريق تحديد موقع الكلمات في كل نتيجة post بالدالة strpos وتقوم بقطع النص بعدها ب 30 حرف مثلا وقبلها كذلك اذا احببت
    وتقوم بتظليل هذه الكلمة بلون مختلف
    اتمنى ان تكون الفكرة واضحة .. للاسف ليس لدي وقت لكتابة مثال شامل لذلك
    لكن اذا لم تستطيع تنفيذها ساعود لكتابة مثال عليها ان شاء الله





    __________________
    قل اللهم مالك المُلك تؤتي الملك من تشاء وتنزع الملك ممن تشاء وتعز من تشاء وتذل من تشاء بيدك الخير انك على كل شىء قدير

  3. #3
    عضو سوبر نشيط
    تاريخ التسجيل
    Jun 2003
    المشاركات
    789


    كود PHP:
    <?php

    /**
     * string substrpos(string $str, mixed $start [[, mixed $end], boolean $ignore_case])
     *
     * If $start is a string, substrpos will return the string from the position of the first occuring $start to $end
     *
     * If $end is a string, substrpos will return the string from $start to the position of the first occuring $end
     *
     * If the first character in (string) $start or (string) $end is '-', the last occuring string will be used.
     *
     * If $ignore_case is true, substrpos will not care about the case.
     * If $ignore_case is false (or anything that is not (boolean) true, the function will be case sensitive.
     *        Both of the above: only applies if either $start or $end are strings.
     *
     * echo substrpos('This is a string with 0123456789 numbers in it.', 5, '5');
     *        // Prints 'is a string with 01234';
     *
     * echo substrpos('This is a string with 0123456789 numbers in it.', '5', 5);
     *        // Prints '56789'
     *
     * echo substrpos('This is a string with 0123456789 numbers in it and two strings.', -60, '-string')
     *        // Prints 's is a string with 0123456789 numbers in it and two '
     *
     * echo substrpos('This is a string with 0123456789 numbers in it and two strings.', -60, '-STRING', true)
     *        // Prints 's is a string with 0123456789 numbers in it and two '
     *
     * echo substrpos('This is a string with 0123456789 numbers in it and two strings.', -60, '-STRING', false)
     *        // Prints 's is a string with 0123456789 numbers in it and two strings.'
     *
     * Warnings:
     *        Since $start and $end both take either a string or an integer:
     *            If the character or string you are searching $str for is a number, pass it as a quoted string.
     *        If $end is (integer) 0, an empty string will be returned.
     *        Since this function takes negative strings ('-search_string'):
     *            If the string your using in $start or $end is a '-' or begins with a '-' escape it with a '\'.
     *            This only applies to the *first* character of $start or $end.
     */

    // Define stripos() if not defined (PHP < 5).
    if (!is_callable("stripos")) {
        function 
    stripos($str$needle$offset 0) {
            return 
    strpos(strtolower($str), strtolower($needle), $offset);
        }
    }

    function 
    substrpos($str$start$end false$ignore_case false) {
        
    // Use variable functions
        
    if ($ignore_case === true) {
            
    $strpos 'stripos'// stripos() is included above in case it's not defined (PHP < 5).
        
    } else {
            
    $strpos 'strpos';
        }

        
    // If end is false, set it to the length of $str
        
    if ($end === false) {
            
    $end strlen($str);
        }

        
    // If $start is a string do what's needed to make it an integer position for substr().
        
    if (is_string($start)) {
            
    // If $start begins with '-' start processing until there's no more matches and use the last one found.
            
    if ($start{0} == '-') {
                
    // Strip off the '-'
                
    $start substr($start1);
                
    $found false;
                
    $pos 0;
                while((
    $curr_pos $strpos($str$start$pos)) !== false) {
                    
    $found true;
                    
    $pos $curr_pos 1;
                }
                if (
    $found === false) {
                    
    $pos false;
                } else {
                    
    $pos -= 1;
                }
            } else {
                
    // If $start begins with '\-', strip off the '\'.
                
    if ($start{0} . $start{1} == '\-') {
                    
    $start substr($start1);
                }
                
    $pos $strpos($str$start);
            }
            
    $start $pos !== false $pos 0;
        }

        
    // Chop the string from $start to strlen($str).
        
    $str substr($str$start);

        
    // If $end is a string, do exactly what was done to $start, above.
        
    if (is_string($end)) {
            if (
    $end{0} == '-') {
                
    $end substr($end1);
                
    $found false;
                
    $pos 0;
                while((
    $curr_pos strpos($str$end$pos)) !== false) {
                    
    $found true;
                    
    $pos $curr_pos 1;
                }
                if (
    $found === false) {
                    
    $pos false;
                } else {
                    
    $pos -= 1;
                }
            } else {
                if (
    $end{0} . $end{1} == '\-') {
                    
    $end substr($end1);
                }
                
    $pos $strpos($str$end);
            }
            
    $end $pos !== false $pos strlen($str);
        }

        
    // Since $str has already been chopped at $start, we can pass 0 as the new $start for substr()
        
    return substr($str0$end);
    }

    ?>
    بحث سريع فى php.net وهذى الدلاله المطلوبه، وأيضاً قم بتغير الدالات المعنيه اذا كنت تستخدم UTF-8





    __________________
    متى استعبدتم الناس وقد ولدتهم أمهاتهم أحرار........
    -----------------------------------
    شبكة الشعر الادبيه





ضوابط المشاركة

  • لا تستطيع إضافة مواضيع جديدة
  • لا تستطيع الرد على المواضيع
  • لا تستطيع إرفاق ملفات
  • لا تستطيع تعديل مشاركاتك
  •  

أضف موقعك هنا| اخبار السيارات | حراج | شقق للايجار في الكويت | بيوت للبيع في الكويت | دليل الكويت العقاري | مقروء | شركة كشف تسربات المياه | شركة عزل اسطح بالرياض | عزل فوم بالرياض| عزل اسطح بالرياض | كشف تسربات المياة بالرياض | شركة عزل اسطح بالرياض