handling data[] from form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mkaye
Forum Newbie
Posts: 8
Joined: Sat Oct 29, 2005 9:40 am

handling data[] from form

Post by mkaye »

i have a loop (Smarty) in my form to output data. I don't want to generate a unique field name for each column so i am trying to use the [] syntax.
I look at the POST data & i have an array for each field, but i can't seem to access it??
i try print_r($_POST['<fieldname>']) and i get Array1, even tho print_r($_Post) shows <fieldname> as an Array
Am i missing something basic?

mark

PHP 5.1.2
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what exactly are you passing to print_r()?
santosj
Forum Contributor
Posts: 157
Joined: Sat Apr 29, 2006 7:06 pm

Post by santosj »

I think this belongs in the other forum for help.

If you don't show any more code then I can't really help you. I'll need to see the form HTML.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Moved to PHP Code
User avatar
PrObLeM
Forum Contributor
Posts: 418
Joined: Sun Mar 07, 2004 2:30 pm
Location: Mesa, AZ
Contact:

Post by PrObLeM »

Code: Select all

$n = count($_POST['FeildName']);
for($i=0;$i<$n;$i++) {
echo "FeildName[" . $i . "] = " . $_POST['FeildName'][$i] . "<br/>";
}
maybe this will help
mkaye
Forum Newbie
Posts: 8
Joined: Sat Oct 29, 2005 9:40 am

Post by mkaye »

here is the form:

{foreach from=$nonR00list key=key item=row}
<tr>
<td align="center">{$row.ProductName}
<input type="hidden" name="ProductName[]" value="{$row.ProductName}">
<input type="hidden" name="InventoryAudit_ProductID[]" value="{$row.InventoryAudit_ProductID}">
<input type="hidden" name="ProductID[]" value="{$row.ProductID}">
<input type="hidden" name="isAdjusted[]" value="{$row.isAdjusted}">
</td>
<td align="right">{$row.WILMAQty}
<input type="hidden" name="WILMAQty[]" value="{$row.WILMAQty}">
</td>
<td align="right">
{if $row.adjustChk ne "CHECKED"}
<input name="Qty[]" type="text" maxlength=3 size="3" value="{$row.Qty}">
{else}
{$row.Qty}<input type="hidden" name="Qty[]" value="{$row.Qty}">
{/if}
</td>
<td><input type="checkbox" name="adjustChkDisable[]" value="CHECKED" {$row.adjustChk} {$row.adjustChkDisable}></td>
</tr>
{/foreach}

here is my code:
die(print_r($_POST)); > OK result - says ProductName is an array
die(print_r($_POST["ProductName"])); > produces "Array1"
mkaye
Forum Newbie
Posts: 8
Joined: Sat Oct 29, 2005 9:40 am

Post by mkaye »

i am still having trouble

in my form i have
<select name="QuestionAnswer[]">
<option selected>{$question.QuestionAnswer}</option>
... list omitted...
</select>

in my code

print_r($_POST['QuestionAnswer']) = Array1

i must be missing something very simple - please point it out to me

mark
Post Reply