Re: Stings .. Strings .. Strings .. help

From: Date: Mon, 16 Sep 2002 16:27:10 +0000
Subject: Re: Stings .. Strings .. Strings .. help
References: 1 2 3 4 5 6  Groups: php.general 
Request: Send a blank email to php-general+get-116543@lists.php.net to get a copy of this message
it shouldn't matter if its a dropdown or textfield. having [] define an array form object. [html] <select name="var[]"> <option value="1">1</option> . . . </select> <select name="var[]"> <option value="a">a</option> . . . </select> <select name="var[]"> <option value="1a">1a</option> . . . </select> <input type="submit" name="submit" value="Submit"> [/html] [php] foreach($_POST["var"] as $_key => $_value) { echo "$_value<br>"; } [/php] [result] 1<br> a<br> 1a<br> [/result] Mohd_q wrote:
I forget to say that the values in the form are in drop-down not text boxes. ----- Original Message ----- From: "Mohd_Q" <ma1420@hotmail.com> To: <php-general@lists.php.net> Sent: Monday, September 16, 2002 6:46 PM Subject: Re: [PHP] Stings .. Strings .. Strings .. help
Unfortunately, no .. it doesn't work. I think if I do it using {}, it might work. Thanks J. Holmes. ----- Original Message ----- From: "1LT John W. Holmes" <holmes072000@charter.net> To: "Mohd_Q" <ma1420@hotmail.com>; <php-general@lists.php.net> Sent: Monday, September 16, 2002 6:38 PM Subject: Re: [PHP] Stings .. Strings .. Strings .. help
Say you have 3 text boxes, like this: <input type='text' name='var[]' value='one'> <input type='text' name='var[]' value='two'> <input type='text' name='var[]' value='three'> Then, on your processing page, you'll have a variable $_POST['var']
that'll
be an array that'll contain the contents of each text box. $_POST['var'][0] => one $_POST['var'][1] => two $_POST['var'][2] => three Does that help? ---John Holmes... ----- Original Message ----- From: "Mohd_Q" <ma1420@hotmail.com> To: <php-general@lists.php.net> Sent: Monday, September 16, 2002 11:30 AM Subject: Re: [PHP] Stings .. Strings .. Strings .. help
Thanx J. Holmes ... Good suggestion .. I did try that but how to get results .. I failed too. Mohd Q. ----- Original Message ----- From: "1LT John W. Holmes" <holmes072000@charter.net> To: "Mohd_Q" <ma1420@hotmail.com>; <php-general@lists.php.net> Sent: Monday, September 16, 2002 6:31 PM Subject: Re: [PHP] Stings .. Strings .. Strings .. help
Name your form elements as var[ ], instead of var1, var2, etc, and
you'll
already have an array with $_POST['var'] that holds the values. ---John Holmes... ----- Original Message ----- From: "Mohd_Q" <ma1420@hotmail.com> To: <php-general@lists.php.net> Sent: Monday, September 16, 2002 11:21 AM Subject: [PHP] Stings .. Strings .. Strings .. help Help .. please .. There is a form where I have variables var1 , var2 , var3, var4 ... ok .. when these variables are submitted, I tried to assign them to an
array
BUT   I    FAILED .
I tried something like :
       while ($i <= $varCount){
               $tchr[$i] = $_POST["({var$i})"];
               $i++;
       }
but no good .. any help .. Thanx MQ. -- 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
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.general (#116543) next »