Re: Array Question

From: Date: Tue, 26 Mar 2002 18:50:42 +0000
Subject: Re: Array Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-90243@lists.php.net to get a copy of this message
I can make this just a little easier.. try this $query = "SELECT * FROM mytable WHERE t_state_id_state in ('" .join("', '", $state). "')"; if $state happens to be the name of the array that is passed from the multi-select Jim Lucas www.bend.com ----- Original Message ----- From: "Rick Emery" <remery@excel.com> To: "'John Fishworld'" <john@webital.de>; <php-general@lists.php.net> Sent: Tuesday, March 26, 2002 10:07 AM Subject: RE: [PHP] Array Question > $n =sizeof($state); > > $srch = ""; > while( $x=0; $x<$n; $x++) > { > ... do something with array element $state[$x] ... > $srch .= $state[$x].", "; > } > $srch = rtrim($srch,", "); > $query = "SELECT * FROM mytable WHERE t_state_id_state in ($srch)"; > > -----Original Message----- > From: John Fishworld [mailto:john@webital.de] > Sent: Tuesday, March 26, 2002 11:51 AM > To: php-general@lists.php.net > Subject: [PHP] Array Question > > > I have some multiple select boxes in a form > ie > <SELECT name="state[]" multiple size=5 style="width:360;"> > <option value="all">all Regions </option> > <option value="16">Region19 </option> > <option value="14">Region14</option> > <option value="5">Region15</option> > > these then get passed and I want to use them in mysql query > > blah blah > WHERE > (t_state_id_state = $state[0]) > > Whats the best way of finding out how many items are in my array ? > And how can I step through the ones the exist ? > And can I only use LIKE % when my value is all ? > > thanks > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#90243) next »