I use PHP to check the search form's input fields then add them to the SQL
statement if they contain data. And if you want the search to return all
records from the table (let's hope there's not many then) if no search terms
are provided then make the "WHERE" part of your SQL query an option based on
having one or more of the search fields populated. If there are fields
populated, include the WHERE and the search criteria. If not, just do your
SELECT without the WHERE clause.

I remember this topic coming up in the past so you should also check the PHP
mailing list archives for others who have requested assistance building
optional keyword searches such as this.

As far as the frameset goes, you'll have to noodle out the HTML for that
yourself or find stuff on other mailing lists or web sites as that
discussion is outside the scope of this list, but it appears that you have
the logic down for creating your link.



Rich


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Friday, July 23, 2004 12:47 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Help with search form using multiple fields 
> 
> 
> 
> I have a search form on a page that i am having trouble with. 
> i can not seem to get the search string correct. In the form 
> i have firstname, lastname, homephone, and email. I would 
> like to upon search return data put in form. for example if i 
> put "john" in firstname i want all rows where firstname is 
> john to return. or if "john" is entered in firstname and 
> "smith" is entered in lastname it will return all rows 
> containing john smith. I have a frame set to display the data 
> on the same page as the search page. I would also loke to 
> data to print as a hyperlink pointing to 
> userdata.php?custid={the PK ID of custid }. also if no text 
> is entered and just search is pressed it will return all data 
> in table asc by lastname. 
> 
> could someone please help with this? 
> 
> 
> Thanks
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to