Mark, Tutorials: Start at the PHP home page and look for the links page. DevShed would be a good start. Regards, =dn
----- Original Message ----- From: "Mark Stringham" <[EMAIL PROTECTED]> To: "DL Neil" <[EMAIL PROTECTED]>; "Peter Lovatt" <[EMAIL PROTECTED]>; "MySQL" <[EMAIL PROTECTED]> Sent: 28 March 2002 19:16 Subject: Re: SQL query question - using LIKE > DL - > > Points well taken - > I am using php and doing simple validation > EX - if ($fname !="") { > add fname string to search variable; > } > > And if none of the fields have been filled out I'll return an error msg. > As you mentioned, Peter's logic still applies here and it has given me > enough to work with. > But I am certainly open for more suggestion/ feedback. > > Thanks > > Mark > > > > > -----Original Message----- > From: DL Neil <[EMAIL PROTECTED]> > To: Peter Lovatt <[EMAIL PROTECTED]>; Mark Stringham > <[EMAIL PROTECTED]>; MySQL <[EMAIL PROTECTED]> > Date: Thursday, March 28, 2002 11:52 AM > Subject: Re: SQL query question - using LIKE > > > >Mark, Peter, > > > >The query below assumes that the user will search of FirstName and none > >or more of the other fields - which was not how the question reads (to > >me). > > > >To answer the question it would be useful to know how you are accessing > >MySQL - are you using PHP (as per example code below) for example? > > > >When the form data is received it is (very) necessary to 'clean' and > >validate the data. Part of this process involves the question "was this > >field filled out?". Thus front end-processing is the time for the > >query's WHERE clause to be built up. The last question is going to be > >"has at least one field been filled out?"! > > > >The methodology of Peter's reply still applies. There are a number of > >tutorials available on various sites (but can't point you at one because > >don't know which tool you're using!!!). Would certainly recommend > >researching a few... > > > >Regards, > >=dn > > > > > >> $query = 'SELECT * > >> FROM Table > >> WHERE > >> FirstName LIKE "%'.$firstname.'%"' ; > >> if($lastname)$query.= ', AND LastName LIKE > >"%'.$lastname.'%"'; > >> if($region)$query.= ', AND Region LIKE "%'.$region.'%"'; > >> if($loan_officer)$query.= ', AND Loan_officer LIKE > >> "%'.$loan_officer.'%"'; > >> etc..... > >> > >> $mysql_result = mysql_query($query, $mysql_link); > >> > >> HTH > >> > >> Peter > >> > >> ----------------------------------------------- > >> Excellence in internet and open source software > >> ----------------------------------------------- > >> Sunmaia > >> www.sunmaia.net > >> [EMAIL PROTECTED] > >> tel. 0121-242-1473 > >> ----------------------------------------------- > >> > >> > -----Original Message----- > >> > From: Mark Stringham [mailto:[EMAIL PROTECTED]] > >> > Sent: 28 March 2002 17:21 > >> > To: MySQL > >> > Subject: SQL query question - using LIKE > >> > > >> > > >> > I have a simple search form that allows the user to search a > >contact db > >> > based on criteria that they choose. > >> > Search by - > >> > first name - text box > >> > last name - text box > >> > region - drop down > >> > loan officer - drop down > >> > > >> > I want the user to be able to receive results if they choose all > >possible > >> > criteria or just one criteria. > >> > My question is about query structure. How do I query the database > >when I > >> > have multiple criteria selected? > >> > > >> > > >> > Any help is appreciated. > >> > > >> > Mark > >> > > >> > > >> > >> --------------------------------------------------------------------- > >> > Before posting, please check: > >> > http://www.mysql.com/manual.php (the manual) > >> > http://lists.mysql.com/ (the list archive) > >> > > >> > To request this thread, e-mail <[EMAIL PROTECTED]> > >> > To unsubscribe, e-mail > >> > <[EMAIL PROTECTED]> > >> > Trouble unsubscribing? Try: > >http://lists.mysql.com/php/unsubscribe.php > >> > > >> > >> > >> --------------------------------------------------------------------- > >> Before posting, please check: > >> http://www.mysql.com/manual.php (the manual) > >> http://lists.mysql.com/ (the list archive) > >> > >> To request this thread, e-mail <[EMAIL PROTECTED]> > >> To unsubscribe, e-mail > ><[EMAIL PROTECTED]> > >> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > >> > >> > > > > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php