Ask a Question related to PHP Development, Design and Development.
-
John W. Holmes #1
Re: [PHP] easier than switch
skate wrote:
If you're really sure only one will be sent:> okay, so i know there's an easy way to do this, and i've seen it done, sure of it. so please forgive the stupidity of my question, i don't even know where to begin to look in the archives either...
>
> i have several forms on one page, they all submit a different variable, i then want to set one variable depending on that... okay, now i'm confusing myself, lets try explain it with some code...
>
> <?
>
> if(isset($_POST))
> {
> $type = $_POST['news'] || $_POST['dreams'] || $_POST['storys'] || $_POST['words'] || $_POST['chat'];
> }
>
> ?>
>
> obviously this doesn't work. but i wanna set $type depending on which $_POST variable was sent. only one of these will ever be sent. rather than doing a big ass switch statement, is there no way i can get this into one line?
>
> i hope this isn't too confusing...
>
$type = $_POST['news'] . $_POST['dreams'] . $_POST['storys'] .
$_POST['words'] . $_POST['chat'];
will achieve what you're looking for.
--
---John Holmes...
Amazon Wishlist: [url]www.amazon.com/o/registry/3BEXC84AB3A5E/[/url]
PHP|Architect: A magazine for PHP Professionals – [url]www.phparch.com[/url]
John W. Holmes Guest
-
Macrons, there must be an easier way...
Hi, I've had a look @ the forum search & manual... but am still confused as to a simple (or any) approach to creating macrons. This is something I... -
easier than switch
On Mon, Aug 04, 2003 at 11:19:42PM +0100, skate wrote: You have a single page, containing multiple forms, all of which share the same action? ... -
[PHP] Is there an easier way?
Hello, This is a reply to an e-mail that you wrote on Fri, 1 Aug 2003 at 02:04, lines prefixed by '>' were originally written by you. statement... -
Is there an easier way?
Hi, This is what i am doing, querying a database via a select statement (getting max 5 records), then dumping everything into an associative array.... -
Tell me how it was easier???
Your steps: 1. Draw 5 filled squares. 2. Group the squares. 3. Double click the contents to change the color of the fills. 4. Duplicate the group... -
Chris Shiflett #2
Re: [PHP] easier than switch
--- skate <root@fatcuban.com> wrote:
The best solution would be to change this behavior, or at least add a> i have several forms on one page, they all submit a different variable
consistent form variable that you plan to receive.
What you need to do is name your variable 'type', so that $_POST['type'] is> <?
> if(isset($_POST))
> {
> $type = $_POST['news'] || $_POST['dreams'] || $_POST['storys'] ||
> $_POST['words'] || $_POST['chat'];
> }
> ?>
>
> obviously this doesn't work. but i wanna set $type depending on which
> $_POST variable was sent.
either 'news', 'dreams', 'stories', 'words', or 'chat'.
Hope that helps.
Chris
=====
Become a better Web developer with the HTTP Developer's Handbook
[url]http://httphandbook.org/[/url]
Chris Shiflett Guest
-
Nicholas Robinson #3
Re: [PHP] easier than switch
As, in this case, only one of the variables is non-null, then you could use
the string concatenation operator and this would return what you want.
i.e. type = $_POST['news'] . $_POST['dreams'] . $_POST['storys']...
I think I've used the same variable name in different forms on the same page,
as only one form submission occurs at any one time there can't be a conflict
and PHP doesn't care where the POST'ed variable came from.. So, you could
rename news, dreams, etc. to be type and extract the result directly without
having to fiddle around.
HTH
Nick
On Monday 04 Aug 2003 11:19 pm, skate wrote:> okay, so i know there's an easy way to do this, and i've seen it done, sure
> of it. so please forgive the stupidity of my question, i don't even know
> where to begin to look in the archives either...
>
> i have several forms on one page, they all submit a different variable,i
> then want to set one variable depending on that... okay, now i'm confusing
> myself, lets try explain it with some code...
>
> <?
>
> if(isset($_POST))
> {
> $type = $_POST['news'] || $_POST['dreams'] || $_POST['storys'] ||
> $_POST['words'] || $_POST['chat']; }
>
> ?>
>
> obviously this doesn't work. but i wanna set $type depending on which
> $_POST variable was sent. only one of these will ever be sent. rather than
> doing a big ass switch statement, is there no way i can get this into one
> line?
>
> i hope this isn't too confusing...Nicholas Robinson Guest
-
Mauricio #4
PHP/JavaScript/HTML
Hello folks
I wrote a JavaScript to set the values of a Select html object by client
side. The values are copied from another Select that I create getting the
values from the database. After the user set the values he/she wants to add
it in another form, for example, then press submit button, the values of the
"user" Select object doesn't appears on the next page. What can I do to get
the user selected values in the another page?
Someone could help me?
Thanks!
..:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. :.:.:.
Maurício Alegre Valente
AGP5 Tecnologia da Informação Ltda.
(48) 439-3004
Visite nosso site: [url]www.agp5.com.br[/url]
..:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. :.:.:.
----- Original Message -----
From: "Nicholas Robinson" <npr@bottlehall.freeserve.co.uk>
To: "skate" <root@fatcuban.com>; <php-general@lists.php.net>
Sent: Tuesday, August 05, 2003 4:26 AM
Subject: Re: [PHP] easier than switch
use> As, in this case, only one of the variables is non-null, then you couldpage,> the string concatenation operator and this would return what you want.
>
> i.e. type = $_POST['news'] . $_POST['dreams'] . $_POST['storys']...
>
> I think I've used the same variable name in different forms on the sameconflict> as only one form submission occurs at any one time there can't be awithout> and PHP doesn't care where the POST'ed variable came from.. So, you could
> rename news, dreams, etc. to be type and extract the result directlysure> having to fiddle around.
>
> HTH
>
> Nick
>
> On Monday 04 Aug 2003 11:19 pm, skate wrote:> > okay, so i know there's an easy way to do this, and i've seen it done,i> > of it. so please forgive the stupidity of my question, i don't even know
> > where to begin to look in the archives either...
> >
> > i have several forms on one page, they all submit a different variable,confusing> > then want to set one variable depending on that... okay, now i'mthan> > myself, lets try explain it with some code...
> >
> > <?
> >
> > if(isset($_POST))
> > {
> > $type = $_POST['news'] || $_POST['dreams'] || $_POST['storys'] ||
> > $_POST['words'] || $_POST['chat']; }
> >
> > ?>
> >
> > obviously this doesn't work. but i wanna set $type depending on which
> > $_POST variable was sent. only one of these will ever be sent. ratherone> > doing a big ass switch statement, is there no way i can get this into>> > line?
> >
> > i hope this isn't too confusing...
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.phpMauricio Guest
-
Cpt John W. Holmes #5
Re: [PHP] PHP/JavaScript/HTML
From: "Mauricio" <mauricio@agp5.com.br>
add> I wrote a JavaScript to set the values of a Select html object by client
> side. The values are copied from another Select that I create getting the
> values from the database. After the user set the values he/she wants tothe> it in another form, for example, then press submit button, the values ofget> "user" Select object doesn't appears on the next page. What can I do toWell, if I understand that correctly, you need to use Javascript to "select"> the user selected values in the another page?
all of the options that the user selected to add to the second select box.
If they aren't selected, then they won't be passed to the next page.
---John Holmes...
Cpt John W. Holmes Guest
-
Mauricio #6
Re: [PHP] PHP/JavaScript/HTML
Ok! Now I can see the values in the another page. But each value are passed
with the same name. How can I get all values using PHP script?
On the Address Bar I can see: index.php?slcAdd=1&slcAdd=2&slcAdd=3
But when I get the value using $HTTP_GET_VARS['slcAdd']; it returns just the
last value. What can I do to get them all?
Thanks!
..:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. :.:.:.
Maurício Alegre Valente
AGP5 Tecnologia da Informação Ltda.
(48) 439-3004
Visite nosso site: [url]www.agp5.com.br[/url]
..:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:. :.:.:.
----- Original Message -----
From: "CPT John W. Holmes" <holmes072000@charter.net>
To: "Mauricio" <mauricio@agp5.com.br>; <php-general@lists.php.net>
Sent: Tuesday, August 05, 2003 10:05 AM
Subject: Re: [PHP] PHP/JavaScript/HTML
the> From: "Mauricio" <mauricio@agp5.com.br>> > I wrote a JavaScript to set the values of a Select html object by client
> > side. The values are copied from another Select that I create getting"select"> add> > values from the database. After the user set the values he/she wants to> the> > it in another form, for example, then press submit button, the values of> get> > "user" Select object doesn't appears on the next page. What can I do to>> > the user selected values in the another page?
> Well, if I understand that correctly, you need to use Javascript to> all of the options that the user selected to add to the second select box.
> If they aren't selected, then they won't be passed to the next page.
>
> ---John Holmes...
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.phpMauricio Guest
-
Cpt John W. Holmes #7
Re: [PHP] PHP/JavaScript/HTML
From: "Mauricio" <mauricio@agp5.com.br>
the> On the Address Bar I can see: index.php?slcAdd=1&slcAdd=2&slcAdd=3
> But when I get the value using $HTTP_GET_VARS['slcAdd']; it returns justName your select box as "slcAdd[]" and you'll have all of the values in an> last value. What can I do to get them all?
array.
---John Holmes...
Cpt John W. Holmes Guest
-
Mauricio #8
RES: [PHP] PHP/JavaScript/HTML
Perfect! That's all I had to do.
Thanks!
Maurício
-----Mensagem original-----
De: CPT John W. Holmes [mailto:holmes072000@charter.net]
Enviada em: terça-feira, 5 de agosto de 2003 16:30
Para: Mauricio; [email]php-general@lists.php.net[/email]
Assunto: Re: [PHP] PHP/JavaScript/HTML
From: "Mauricio" <mauricio@agp5.com.br>the> On the Address Bar I can see: index.php?slcAdd=1&slcAdd=2&slcAdd=3
> But when I get the value using $HTTP_GET_VARS['slcAdd']; it returns justName your select box as "slcAdd[]" and you'll have all of the values in an> last value. What can I do to get them all?
array.
---John Holmes...
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.510 / Virus Database: 307 - Release Date: 14/8/2003
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.510 / Virus Database: 307 - Release Date: 14/8/2003
Mauricio Guest



Reply With Quote

