Forum Moderators: coopster
For example, item_ID: s001 , quantity: 5
s002 , 2
s003 , 4
this is code for 1.php
<?
echo "<td align='center'>$item_ID<input type='hidden' name='$item_ID' value='$item_ID'; /></td>";
echo "<td align='center'>$dol_quantity</td>";
echo "<td align='center'>$dol_status</td>";
?>
<select name="$item_ID">
<?php
for ($i=1; $i<=10; $i++) {
echo "<option value='$i'>$i</option>";
} ?>
</select>
this is code for 2.php
foreach( $_POST as $key => $value){
echo $value;
}
The code that you have in 2.php should do what you want and is correct. I'm not exactly sure, then, what you are asking? I'm assuming you are having trouble making 1.php into a form that is correctly submitted to 2.php?
[edited by: eelixduppy at 6:03 pm (utc) on Dec. 23, 2008]
<select name="$item_ID">
<?php
for ($i=1; $i<=10; $i++) {
echo "<option value='$i'>$i</option>";
} ?>
</select>
If there are 4 items then i have to select the quantity for each item.
When post to 2.php, only the last row of the quantity is shown.
How to do i show out the 4 quantities?
pPOST($_POST);
#
function pPOST($arr) {
foreach($arr as $key => $value) {
if(is_array [php.net]($value)) {
echo $key . " => \n";
pPOST($value);
} else {
echo $key . ' => '. $value . "\n";
}
}
}
See what that outputs. :)
Looks like your form is not correct at all. The generated HTML from your PHP in 1.php should closely follow the following format:
<form action="2.php" method="post">
<input type="hidden" name="item_ID" value="s001" />
<select name="quantity">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="hidden" name="item_ID" value="s002" />
<select name="quantity">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
If it doesn't look like that make your PHP output that in 1.php so that it is correct.
If every item i have to choose two qty, how do i post it if i want the name='<? echo $item_ID?>' to be the same?