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 IamaSherpa 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!
 
Place brackets after the name in your input tag. So you have <input type='text' name='alphabet[]'> .. This will store the results of each field in seperate elements of the array alphabet.

Hope this helps,

brendanc@icehouse.net
 
Thanks! I didn't know about that trick. Now I can create my list using a loop.
 
When a form is submitted to a PHP script, any variables from that form will be automatically made available to the script by PHP. If the track_vars configuration option is turned on, then these variables will be located in the associative arrays $HTTP_POST_VARS, $HTTP_GET_VARS, and/or $HTTP_POST_FILES, according to the source of the variable in question.
- tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top