Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

?? for those who know ColdFusion and PHP

Status
Not open for further replies.

minsan

Technical User
Jan 8, 2001
18
US
Here's my code:

<input type=&quot;Text&quot; name=&quot;alphabet&quot; value=&quot;abcd&quot;>
<input type=&quot;Text&quot; name=&quot;alphabet&quot; value=&quot;efgh&quot;>
<input type=&quot;Text&quot; name=&quot;alphabet&quot; value=&quot;ijkl&quot;>

In Cold Fusion, when you output these three form fields that has the same NAME attribute, you will get a 3-item list that contains the three values respectively. Like this:

<cfoutput>#form.alphabet#</cfoutput>

Will give you:

abcd,efgh,ijkl

But if you output this in PHP, you only get the last item that uses that same NAME attribute. Like this:

<?php print(&quot;$alphabet&quot;); ?>

Will give you:

ijkl

My question is, how can I get the itemed list result like it does in Cold Fusion using PHP code? I absolutely have to use the same NAME attribute for all my input text fields. I'll be generating the input fields from a loop so I don't think I can use unique NAME attributes.

Thanks!
 
Hi minsan,

I never used PHP, so I can't realy tell you, but at Tek-Tips you do have a forum called PHP, just do a search on top of this page on PHP...

I'm sure these guys will be able to help you.

Regards
bram
 
In php, you can add [] to the end of the name in the form field. When the form is submitted, php treats this as an array.

example:
<input type=&quot;Text&quot; name=&quot;alphabet[]&quot; value=&quot;abcd&quot;>
<input type=&quot;Text&quot; name=&quot;alphabet[]&quot; value=&quot;efgh&quot;>
<input type=&quot;Text&quot; name=&quot;alphabet[]&quot; value=&quot;ijkl&quot;>

would give:
Code:
Array
(
    [alphabet] => Array
        (
            [0] => abcd
            [1] => efgh
            [2] => ijkl
        )

)

Chad.

ICQ: 54380631
online.dll
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top