john_6767 Posted February 26, 2007 Share Posted February 26, 2007 ok i'm trying to get the value of a posted field that has the name stored in my variable.. is this possible?? $_POST['$My_Variable'] i have some fields named quantity_1, quantity_2, quantity_3 etc so i have also tried $_POST['quantity_'.$My_Variable] .. but no luck, any tips? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted February 26, 2007 Share Posted February 26, 2007 Try this: $phpcode=eval('$myvar=$_POST[\'$My_Variable\'];'); Quote Link to comment Share on other sites More sharing options...
john_6767 Posted February 26, 2007 Author Share Posted February 26, 2007 nope no luck, i changed it to this so i can tell if it works.. any more ideas? if (eval('$_POST[\'$qtyField\'];') > 0) { echo "It is bigger than 0"; } i tried it without the semicolon but no luck there either Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 26, 2007 Share Posted February 26, 2007 $_POST['quantity_'.$My_Variable] That is perfectly valid, as long as $My_Variable is 1, 2, 3, etc. Quote Link to comment Share on other sites More sharing options...
john_6767 Posted February 26, 2007 Author Share Posted February 26, 2007 ok will try Quote Link to comment Share on other sites More sharing options...
john_6767 Posted February 26, 2007 Author Share Posted February 26, 2007 thanks guys, yep the $_POST['quantity_'.$My_Variable] worked now, theres a handy trick for the future Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 26, 2007 Share Posted February 26, 2007 You're the one who posted that, and you said it didn't work... Quote Link to comment Share on other sites More sharing options...
john_6767 Posted February 26, 2007 Author Share Posted February 26, 2007 ..worked now.. i know, must have been something else that was wrong, half my code is commented out so i'm going through it now trying to work out where my error is, thanks for your help though i didn't know it was that easy, i was just taking a stab in the dark. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.