Page 1 of 1

handling data[] from form

Posted: Thu Jun 01, 2006 7:44 am
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

Posted: Thu Jun 01, 2006 9:29 am
by feyd
what exactly are you passing to print_r()?

Posted: Thu Jun 01, 2006 9:31 am
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.

Posted: Thu Jun 01, 2006 9:34 am
by Chris Corbyn
Moved to PHP Code

Posted: Thu Jun 01, 2006 11:10 am
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

Posted: Fri Jun 02, 2006 8:05 am
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"

Posted: Thu Jun 08, 2006 2:19 pm
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