Getting Value

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
glennalmeda
Forum Newbie
Posts: 14
Joined: Mon Jan 26, 2004 9:00 pm

Getting Value

Post 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.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post 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.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Cruzado_Mainfrm
Forum Contributor
Posts: 346
Joined: Sun Jun 15, 2003 11:22 pm
Location: Miami, FL

Post 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']; ?>">
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Yes, he's right, I perhaps wrongly assumed that the form element was being echoed in a heredoc.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
glennalmeda
Forum Newbie
Posts: 14
Joined: Mon Jan 26, 2004 9:00 pm

Post 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
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post 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...?
Post Reply