RE: [PHP] where match question




Don wrote:
I have a db field that contains zip codes separated by comas.

I am trying to get php to return all of the rows that contain a particular
zip code.



$query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip')";

$result = mysql_query($query)

or die ("could not connect to db");

$row = mysql_fetch_row($result);

http://php.net/mysql_fetch_assoc has a better example.

When there are many rows returned you need to loop to show them all:

while ($row = mysql_fetch_assoc($result)) {
print_r($row);
}

Don wrote:
I appreciate your quick response, but I think the problem I'm having
is in the query. Is WHERE MATCH () the proper format to use for
getting multiple rows from the DB? Or is there something else I'm
missing?

Please don't top post, it's hard to follow what's going on and who's
replied.

Sorry, I misread your email.

"Match against" is meant to be for fulltext searches, that includes some
limitations.

http://dev.mysql.com/doc/refman/4.1/en/fulltext-search.html

Specifically the last 3-4 paragraphs.



~~~~~~~

Alright,

I learned 2 things....
What top post is....lol (sorry)

And don't' skim through the manual.... programming isn't like legos where
you can look at the picture and put it together....

query = "SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip' in
Boolean mode)";

Made all the difference... I missed the part about stop words and had only 2
entries in my DB.

So thanks for pointing that out.

Don
.



Relevant Pages

  • beamer: separation of paragraphs
    ... I'm tempted to insert a \smallskip between paragraphs, but since this is LaTeX, ... Einwohner einer Stadt oder die in einer Fabrik hergestellten Schrauben. ... Wir behandeln nur folgende Form der Zufallsstichprobe: ... Die den Elementen der Grundgesamtheit zugeordneten Werte sind also ...
    (comp.text.tex)
  • Re: [PHP] why so slow?
    ... or die; ... or die ("Couldn't execute query2"); ... Yeah it will be that hit counter or whatever it is you are trying to load - I had one myself that used JS and was hosted on another website and held up the page it was on by a good 3-4 seconds, and that was on a good day. ...
    (php.general)
  • RE: [PHP] urlencoding.
    ... I like the die() in there so I can just use an if statement at the ... I haven't done much php and only a little web development in perl. ... I am having the user fill out a form and then save the data in MySQL. ... My problem is that any field that contains a double quote, ...
    (php.general)
  • Re: oracle mystery
    ... I remember in a class i had we needed to connect to an oracle server in ... PHP and seemingly randomly the pages would just die. ... those special accented characters? ...
    (comp.lang.php)
  • Geeklog <=1.5.2 SEC_authenticate()/PHP_AUTH_USER sql injection exploit
    ... software site: http://www.geeklog.net/ ... working against PHP>= 5.0 ... you can inject sql code in the 'username' argument of this function, ...
    (Bugtraq)