Re: multiple search

From: Date: Tue, 23 Jul 2002 08:33:06 +0000
Subject: Re: multiple search
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-109057@lists.php.net to get a copy of this message
After executing the exact script I get the following (rough)error: Warning: Undefined offset: 1 in :/Inetpub/co2_busters_mk2 The script(Which is being executed about 25m away) soon cause my computer to fill up up it's memory(96mb used to about 256) That is why I couldn't give you the message(IE crashed). It is looping forever for some reason(I've never filled a client's computer that fast before!) How can I fix it? Or if you cant tell me what does the error mean? -- JJ Harrison webmaster@tececo.com www.tececo.com "Richard Lynch" <rich@phpbootcamp.com> wrote in message news:php.general-108972@news.php.net... > >My question is what can I do if someone searches for php script for search? > > > >I would want to use OR in my SQL statment. The problem is how do I write the > >query so that it will detect the number of words sent then put enough ORs > >and LIKE '%$search[1]% in? > > The LIKE operator will cheerfully return 1 or 0, which you can "add up", or > in your case, "weight and add up" in your SELECT: > > $query = "select 0 "; > # The 0 is a kind of 'yeast' to start off our summation of matches. > > $words = explode(' ', $search); > > while (list(,$word) = $words){ > $word = trim($word); > if ($word){ > $query .= " + article_keyword.weight * article_keyword.keyword like > '%$word%' "; > } > } > > $query .= " as score "; > $query .= " from article_keyword, article_data "; > $query .= " where score > 0 "; > $query .= " and article_data.aid = article_keyword.aid "; > $query .= " order by score desc "; > > echo $query, "<BR>\n"; > > -- > Like Music? http://l-i-e.com/artists.htm >

« previous php.general (#109057) next »