Reply to Re: Search DB by more than one word

Your name:

Reply:


Posted by paul814 on 01/07/08 17:39

On Jan 7, 12:33 pm, "Paul Lautman" <paul.laut...@btinternet.com>
wrote:
> paul...@excite.com wrote:
> > Hello everyone,
> > Right now I have a simple PHP page setup that takes whatever was
> > entered into txtsearch on the previous page, it searches my DB by that
> > word and brings back the whole record based on the word.
>
> > So if I enter: ALPHA
> > it will bring back this record: the alpha dog was there
>
> > HOWEVER if I enter: ALPHA DOG or alpha dog
> > (so if I enter more than one word) it does not find any records. How
> > can I fix this so that if I enter ALPHA DOG it will find the record:
> > the alpha dog was there
>
> > Here is my code:
> > ==============
> > <?php
> > $host="localhost";
> > $user="root";
> > $pass="";
> > $db="productiondb";
> > $con = mysql_connect($host, $user, $pass);
>
> > $Search = $_POST["txtsearch"];
>
> > if (!$con)
> > {
> > die('Unable to connect: ' . mysql_error());
> > }
> > mysql_select_db($db, $con) or die('Unable to connect: ' .
> > mysql_error());
>
> > $sql = "SELECT * FROM IT WHERE itcomments LIKE '$Search%' ";
> > $rs = mysql_query($sql,$con);
>
> > while($row=mysql_fetch_object($rs)){
>
> > print "<div class=\"message\">";
> > print " <h3 class=\"red\">" . $row->itdate . "</h3>";
> > print " <h5 class=\"red\">" . $row->itname . "</h5>";
> > print " <h4 class=\"red\">" . $row->itcomments ."</h4>";
> > print "############### END OF RECORD ###############";
> > print "</div>";
> > }
> >?>
>
> > thanks for any help
>
> I'm amazed!
> Looking at your code I would not expect searching on "alpha" to bring back
> "the alpha dog was there", since this does not begin with the word "alpha".

Hmm, you are right, I didnt notice that, that was just an example,
not an actual query......hmm, yea if it does not begin with whatever I
search for I do not get a result?...

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация