Re: counting check boxes
| From: | Paul Chvostek | Date: | Sun, 11 May 2003 04:42:44 +0000 |
| Subject: | Re: counting check boxes | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-147185@lists.php.net to get a copy of this message | ||
On Sat, May 10, 2003 at 09:39:50PM +0200, Ryan A wrote:
>
> 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...
Unless you have the source code that procseses their forms, duplicating
their form style seems wrong.
> What do you suggest to get the same functionality?
How about the method I already suggested?
Check http://www.it.ca/~paul/checktest.php for an
example.
p
> ----- 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/
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
Paul Chvostek <paul@it.ca>
Operations / Abuse / Whatever
it.canada, hosting and development http://www.it.ca/