simple search form - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 01-31-2011, 11:26 PM   #1 (permalink)
Junior Member
 
Join Date: Jan 2011
Posts: 1
Default simple search form

So im making a search form, where you type in some words and it brings you to a page where it lists all your results, I use a loop that goes through every word and for now im just trying to check the occurance of each individual word through all the strings that fit into "WHERE description LIKE '%$word%'"

So I got a simple version to work but now im trying to check the number of times each word appears (as described) but the problem im having is that It will only check the first word's number of occurances.

here is the script

PHP Code:
    //variables

    
$search=$_GET['term'];
    
$search_words=explode(' '$search);
    
$search_list = array();


    
    
//looping 

    
foreach ($search_words as $word) {

        
$query mysql_query("SELECT * FROM search WHERE description LIKE '%$word%'");
        echo 
$word;
        while (
$row mysql_fetch_array($query))
        {
        
$string=$row['description'];
        
$subs substr_count($string$word);
        echo 
"row 1: " $subs "<br>";
        echo 
$string;
        echo 
$word;
        echo 
"<p>";
        } 
please help thanks
bs7280 is offline   Reply With Quote
Sponsored Links
Old 02-10-2011, 12:32 PM   #2 (permalink)
Junior Member
 
Join Date: Feb 2011
Posts: 4
Default Re: simple search form

The MySQL match() full-text search function is much better at this.. Try looking into that one..
imsas is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 04:32 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting