"Maciek Sokolewicz" <maciek.sokolew...@gmail.com> wrote in message 
news:4fcf23af.7040...@php.net...
> On 06-06-2012 05:11, Jim Giner wrote:
>> "Govinda"<govinda.webdnat...@gmail.com>  wrote in message
>> news:72497398-3a6c-4faa-89f2-565c18fd2...@gmail.com...
>>
>> On 2012-06-05, at 10:54 PM, Devangnp wrote:
>>
>>> I know how to pass variable but having difficulties when I use the 
>>> dynamic
>>> form field in HTML that add more boxes as per user require.
>>>
>>
>>>>> Hi All,
>>>>>
>>>>> I am a basic user of PHP and I have need of reading the dynamic HTML
>>>>> form
>>>>> field as a variable in PHP so it will be great if someone can share 
>>>>> some
>>>>> good link or snip for quick understanding.
>>>>>
>>>>> Thanks,
>>>>> Devang
>>>>
>>>>
>>>> http://lmgtfy.com/?q=how+to+pass+and+receive+a+PHP+variable
>>>>
>>>> When just starting out, "Google is your friend".
>>>>
>>>> Or did I misunderstand your question?
>>>>
>>>> -Govinda
>>
>>
>> Devang,
>>
>> Please keep replies on-list.
>> Please post your replies at the bottom, past the older (snipped) content.
>>
>> Many here will be glad to help..  but you'll need to make your question 
>> more
>> clear.. at least for me to be able to help anyway.
>> First of all, what do you mean exactly, by, "the dynamic form field in
>> HTML"?  And by "boxes" do you mean form inputs of 'text' type?  If so, 
>> then
>> do you mean to suggest that input by the end user should determine the
>> number of text inputs that should display in a second HTML form?
>> Please spend more time describing what you are trying to do.. and also
>> please show any code you attempt(ed) to accomplish this.  If you are 
>> unable
>> to write any code, then try pseudo code - meaning write in successive 
>> lines
>> of prose what you want code to do, and post that here.
>>
>> -Govinda=
>>
>> I thought he meant previously generated "array" type fields, that use the
>> same name.  I've never done it myself, but  I thought the method of 
>> handling
>> this kind of input included placing a hidden field with the count on the
>> form to be retriieved later and used in processing the dynamic fields in 
>> a
>> loop.
>>
>>
>
> A possible answer to a possible question that he might have (yes, the 
> question is very vaguely described, as Govinda already explained) would be 
> the following:
>
> Assuming you have an HTML form, which may contain a variable number of 
> fields, you want to somehow access their passed-through values in PHP 
> without prior knowledge of the exact number of those fields.
>
> There are essentially 2 ways:
> 1. All POSTed data is present in the $_POST superglobal array. So you 
> could just loop over that, ignore the fields you already knew were there, 
> and the data remaining is then essentially the data you seek. The keys in 
> the $_POST array are the fieldnames you are looking for.
>
> 2. There's a special trick in PHP, when you name a field "name[]" in HTML 
> and then POST it to a PHP script, it will turn into an array field. So 
> <input name="a[]" value="1"> <input name="a[]" value="2"> will then end up 
> in:
> $_POST = [
>    'a' => [
>       0 => '1',
>       1 => '2'
>    ]
> ]
>
> If you had not added the square-brackets, you would have:
> <input name="a" value="1"> <input name="a" value="2"> ending up in:
> $_POST = [
>    'a' => '2'
> ]
> Thus not ever seeing the value '1'.
>
> I hope this answers part of your question; and if not, PLEASE explain in 
> more detail what your problem is, what you tried, why it didn't work, and 
> what you want to know exactly. Your current question is very very short 
> and vague enough to easily cause misunderstanding.
>
> - Tul

Thank you Tul for your eloquent post.  Now I understand how to handle those 
kinds of "array" inputs myself!

And - I do think from his vague description that the OP is looking for this 
kind of help.  If not, then it was REALLY vague! 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to