Re: How to process a query form with CHECKBOX Please help

From: Date: Tue, 28 Dec 2004 08:11:32 +0000
Subject: Re: How to process a query form with CHECKBOX Please help
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-205231@lists.php.net to get a copy of this message
<DIV>Young<input type="checkbox" name="agegroup[]" value="young"></DIV> <DIV>Middle<input type="checkbox" name="agegroup[]" value="middle"></DIV> <DIV>Old<input type="checkbox" name="agegroup[]" value="old"> note that the name of all three is "agegroup[]". this ensures that it stores the values in an array "$agegroup". now on the next page, you can simply say $ageresult=implode(" and ",$agegroup); now, your query is simply: Select age_group from patient_data where age_group = $ageresult; You might wanna change the "and" to "or". if it's one column in the db that has one value of the age group (young, middle, or old), i think your best bet would be "or". cheers, Ospinto. "S Kumar" <ps_php@yahoo.com> wrote in message news:20041228012249.26315.qmail@web30902.mail.mud.yahoo.com... > Dear group, > I am a novice programmer started doing php to process > a query form of my patients. > > I have a database and one table in it deals with my > patient information. Depending on their condition I > divided their age groups into 3 categories. In my > database a table patient_data has a column age_group > and a patient can be any one of young, middle or old > category. > Now the possibility is that a user can selecct 1 or 2 > or all three options. > > In the query form, I gave the option for a user as a > check box. The piece of html code is as below: > > <DIV>Age group</DIV> > <DIV>Young<input type="checkbox" name="" > value=""></DIV> > <DIV>Middle<input type="checkbox" name="" > value=""></DIV> > <DIV>Old<input type="checkbox" name="" > value=""></DIV> > > Problem: > I want to capture the user options and create an SQL > statement: > > Select age_group from patient_data where age_group = > young and old ; > > > I am truly stuck here. Can any one please help me out > to pass this situation. > > Thank you in advance. > > Kumar. > > > > > __________________________________ > Do you Yahoo!? > Yahoo! Mail - You care about security. So do we. > http://promotions.yahoo.com/new_mail

« previous php.general (#205231) next »