I'm not sure if I understand...

first of all, I could be wrong, but I thought that you had to use the 
LIKE operator rather than "=" (equals sign) when trying to match text 
strings.  But like I said, I could be wrong.

if you did

$query = "SELECT * FROM tabe WHERE lastname LIKE '$lastname' OR 
firstname LIKE '$firstname' OR age LIKE '$age' OR weight LIKE '$weight'";

Then it might do what you want.  This will return the results when any 
of the fields match, rather than ALL of them.  But keep in mind that it 
could very likely increase the number of returned results significantly.


On Tuesday, January 15, 2002, at 03:53  PM, Phil Schwarzmann wrote:

> Yo, thanks for all your help.  But it isn't exactly what im looking for.
> Let's say you had a database with the following four columns...
> -LastName
> -FirstName
> -Age
> -Weight
> ...and you wanted a page that would allow a user to search for one or 
> more of these fields within the database.
> It would be easy if the user could only pick just one of the fields.  
> But let's say that want to search only lastname and firstname, or maybe 
> all four, or maybe just one.  How could this be done?
> If I have code that looks like this...
> $query = "select * from table where lastname='$lastname' and 
> firstname='$firstname' and age='$age' and weight='$weight'";
> $result  = mysql_query ($query);
> $num_results = mysql_num_rows($result);
> ...the $num_results is ALWAYS zero unless I typed in all four fields. 
> Any help?
> Thanks!

PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to