Why not have each one look like this:

if (isset($HTTP_GET_VARS['check00'])) {
        $SQL .= "penpals.agegroup = '00' OR";
}

Then after you go through them all, strip the last two characters (the
trailing OR) and then attach and AND

That way it will accommodate any checks, and because you rip the last or
and replace it with an and, you are always Ok for what follows.

> -----Original Message-----
> From: vernon [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, June 19, 2003 1:49 PM
> To: Mike Hillyer
> Subject: RE: Complex SQL involving 10 checkboxes
> 
> 
> > if (isset($HTTP_GET_VARS['check00'])) {
> >     $SQL .= "penpals.agegroup = '00' OR";
> > }
> 
> Because there is a statement after these that neends to have the AND 
> statement.
> 
> > This is probably a question for the PHP general mailing 
> list as it is
> > more a code question. 
> 
> There I always get them telling me to come here, SQL issue. :(
> 
> > Essentially you just build the query in 
> > chunks. By the nature of checkboxes you probably just need Ors, not 
> > ANDs. You may need to rip the trailing OR, maybe replacing it with 
> > an AND if you need to add some other condition on the end 
> that needs 
> > an AND. Unless of course someone can belong to more than one 
> > agegroup. If so you better post what the table looks like.
> 
> It's not that they belong to more than one age group they may 
> be looking for 
> more than one age group, which is the case (it's a dating site). The 
> statement immidiately after words MUST have the AND 
> statement. My only 
> problem is with the checkboxes. Maybe they select only one in 
> which case it 
> needs and AND if they select more than one it needs an OR and 
> AND on the 
> last one. Make sense?
> 
> V
> 

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to