Re: MySQL with php

[email protected] ("Bsantos PHP") Wed, 25 Sep 2002 11:20:27 +0100
Newsgroups php.lang
Message-ID <[email protected]>
bsantos on 2002/09/25:

You know Jan... there's a old sy here in Portugal: "It is a either a Bull or
a Cow"!!

Shure the script'll not work! You see: no name can be X and Y at same time.
You're querying to obtain a name which must be twice at same time and that
doesn't exist.

In my opinion, you should do as most people do.

1. Create separated fields for firstname and lastname in DB:

ALTER TABLE names ADD fisrtname varchar(128) not null;
ALTER TABLE names ADD lastname varchar(128) not null;

2. Construct the script to make it happend:

Here you can make thinks different ways, it's a so "your call doc!!!!"
Anyway, some tips:

mysql_query("SELECT firstname, lastname FROM names WHERE firstname ='peter'
AND lastname='pan'");
...
or something like that...
...

bsantos

"Jan" <[email protected]> wrote in message
news:[email protected]...
> Hello
> i've a simple question i think ;)
> if i want to do a query with 2 keywords in a MySQL database, how do i
write
> it in my script?
>
> ie.  I want to search for name=peter pan   with the keywords "pan" and
> "peter"
>
> I thought it's like this:
> $query=SELECT ... FROM ... WHERE name LIKE '%pan%' AND LIKE '%peter%'
>
> but this isn't working :(
>
> hope somebody can help me out.
>
> thanks,
>
>
> Jan
>
>