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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parsing checkboxes

Status
Not open for further replies.

Garabaldi

Technical User
Joined
Jan 16, 2002
Messages
61
Location
CA
Folks,

I've been reading the posts here about parsing froms with fields which have multiple values. The standard reply has been to include a [] after the form field name.

Example:
<form method=&quot;post&quot; action=&quot;posted.php&quot;>
<input type=&quot;checkbox&quot; name=&quot;System[]&quot; value=&quot;One&quot;>
<input type=&quot;checkbox&quot; name=&quot;System[] value=&quot;Two&quot;>
<input type=&quot;submit&quot;>
</form>

then on the page where i am calling System i have
<%
$System = $_POST['System']

echo $System&quot;<br>&quot;
%>

All I get is the word Array.

If anyone can tell me where I've fudged up on it would be appreciated.

Thanks,
 
Array variables need to be printed recursively since there might be multiple values.

For just a printout of the array use
Code:
print_r($_POST[System]);
Another tip:
The browser output of print_r is not pretty, since the &quot;\n&quot; linebreaks are not honored. Look at the HTML source of the page and you'll see a better rendering.

This will not help you in terms of presentation. If you want to display all the elements use a loop that iterates the array:
Code:
foreach($_POST[System] as $key=>$value){
   # any formatting in here
   print &quot;Value $key: $value&quot;;
}
 
Thank you very much... the code works like a charm...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top