Re: counting check boxes

From: Date: Sat, 10 May 2003 19:39:50 +0000
Subject: Re: counting check boxes
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-147143@lists.php.net to get a copy of this message
Hi guys, Thanks for replying. Yes, I know its an ugly form and its pretty unusual... but I am just trying to copy the functionality of this site: http://hostfilter.com/plans_showresults.asp?price=30&diskspace=5&plat=All&Su bmit=Filter+It+%21&ps=20 If you run the above query you will see a row of checkboxes and at the bottom a way to compare plans...thats exactly what i want to do... After going through their source i see their checkboxes are all named "planid" so i did the same for mine... What do you suggest to get the same functionality? Kindly reply, -Ryan ----- Original Message ----- From: "Paul Chvostek" <paul+php@it.ca> To: "Ryan A" <ryan@jumac.com> Cc: <php-general@lists.php.net> Sent: Saturday, May 10, 2003 8:55 PM Subject: Re: counting check boxes > On Sat, May 10, 2003 at 08:35:25PM +0200, Ryan A wrote: > > > > I have run into a little problem, its hard to explain so am giving you the > > whole code below: > > I am getting a string to countchecks.php which is like: > > countchecks.php?id=154&id=198&id=505&id=809&id=1100 > > Ugh. > > If you're stuck with this format, then you're going to have to parse > $_SERVER['QUERY_STRING'] manually, because repetitions of the same > variable will overwrite each other. So $_GET['id'] will be 1100, and > the other values will be lost. > > > taking that I have to format it into > > > > select * from asdf where id=154 and id=198 and id=505 and id=809 and > > id=1100; > > > > How can i do that? > > Why would you want to? How can 'id' have multiple values? > > Anyway, it would be something like: > > foreach (explode('&',$_SERVER['QUERY_STRING']) as $this) { > list($junk,$value)=explode('=',$this); > if ($junk=="id") $q.=" AND id=$value"; > } > $q="SELECT * FROM asdf WHERE" . substr($q,5) . ";"; > > > Below is the form that i am using... > ... > > It's an ugly form. You'd have an easier time if you put the checkbox > entities into an array, with: > > <form method="get"> > ... > <input type="checkbox" name="id[]" value="154">154 > <input type="checkbox" name="id[]" value="198">198 > <input type="checkbox" name="id[]" value="202">202 > <input type="checkbox" name="id[]" value="505">505 > <input type="checkbox" name="id[]" value="809">809 > <input type="checkbox" name="id[]" value="1100">1100 > <input type="submit" name="Submit" value="Submit form"> > </form> > > and processed it with: > > foreach ($id as $value) { > $q.=" AND id=" . $value; > } > $q="SELECT * FROM asdf WHERE" . substr($q,5) . ";"; > > -- > Paul Chvostek <paul@it.ca> > Operations / Abuse / Whatever > it.canada, hosting and development > http://www.it.ca/ >

« previous php.general (#147143) next »