Page 1 of 1

Getting Value

Posted: Tue Feb 10, 2004 11:11 am
by glennalmeda
Help Pls...
i have this page let say its file name is orderlist.php, and i have drop down for each products in the order list.


php:
--------------------------------------------------------------------------------
<select size="1" name="reqmonth'.$row['o_mod_id']. '">
?>

--------------------------------------------------------------------------------


i believe that my concatenation of the name of the dropdown is ok.
but by clicking submit button, on the next page (submit.php)
how will i be able to get the value of the drop down from the previous page (orderlist.php)?
i tried this code



php:
--------------------------------------------------------------------------------
$reqMonth = $_POST["reqmonth$o_mod_id"];
?>

--------------------------------------------------------------------------------


but didnt work..
please help me.. thanks.

Posted: Tue Feb 10, 2004 12:26 pm
by pickle
$row['o_mod_id'] will evaluate to whatever value is in the array at that index. So, if $row['o_mod_id'] = 4, then your select name would be "reqmonth4". Uness you know what the value will be, the only way to get that post item will be to loop through the POST array. Try REALLY hard to set up your form so that the select has a static name - it'll make your life much easier when you're trying to retrieve that select's value.

Posted: Tue Feb 10, 2004 2:29 pm
by Cruzado_Mainfrm
actually is not right at ALL
this:
<select size="1" name="reqmonth'.$row['o_mod_id']. '">
?>

should be this:

Code: Select all

<select size="1" name="reqmonth<?php echo $row['o_mod_id']; ?>">

Posted: Tue Feb 10, 2004 2:40 pm
by pickle
Yes, he's right, I perhaps wrongly assumed that the form element was being echoed in a heredoc.

Posted: Tue Feb 10, 2004 7:39 pm
by glennalmeda
let say this is my code now

assume:

Code: Select all

$row['o_mod_id'] = 4

<select size="1" name="reqmonth<?php echo $row['o_mod_id']; ?>">
now the name of the drop down is "reqmonth4" ryt?

but how can i retrieve the value on the next page?

Code: Select all

$o_mod_id = 4
$reqMonth = $_POST["reqmonth$o_mod_id"];
is this correct? will i be able to get the value? ty

Posted: Tue Feb 10, 2004 8:06 pm
by McGruff
It's rather alarming to hear "help please" and "products in the orders list" in the same post.

Is this going to be a real, live online shop...?