phatgreenbuds Posted October 2, 2008 Share Posted October 2, 2008 Consider the code below. How would I pass both the "$tblname" and "$display" through in the POST method? Yes there is a bit of scripting before this that dynamically pulls the values for each and I need to somehow get them POST'd to the next step. Also is there anyway to do this without the need for a submit button? I have seen sites before that change the moment you change the selection and I cannot seem to figure out how to do that. <form action="<?php $_PHP_SELF ?>" method="POST"> <select name="table" size="1"> <option value="<?php echo $tblname ?>"><?php echo $display ?></option> </select> <input type="submit" name="submit" value="Submit"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/126695-solved-passing-variables/ Share on other sites More sharing options...
Lodius2000 Posted October 2, 2008 Share Posted October 2, 2008 $_POST['tblname'] = $tblname; or use $_SESSION that should do it, basically assign those variables to a superglobal just a thought Quote Link to comment https://forums.phpfreaks.com/topic/126695-solved-passing-variables/#findComment-655251 Share on other sites More sharing options...
phatgreenbuds Posted October 2, 2008 Author Share Posted October 2, 2008 the $tblname passes thru fine but its the $display that I am having trouble with. There are 14 pair of those variables that can be chosen so assigning to a global doesn't work as each one has to change according to its partner. Quote Link to comment https://forums.phpfreaks.com/topic/126695-solved-passing-variables/#findComment-655256 Share on other sites More sharing options...
Lodius2000 Posted October 2, 2008 Share Posted October 2, 2008 huh? little more info, maybe a bit more of your script Quote Link to comment https://forums.phpfreaks.com/topic/126695-solved-passing-variables/#findComment-655264 Share on other sites More sharing options...
MasterACE14 Posted October 2, 2008 Share Posted October 2, 2008 hidden field maybe? I don't really understand your question... <input type="hidden" name="something" value="<?php echo $var; ?>" /> Quote Link to comment https://forums.phpfreaks.com/topic/126695-solved-passing-variables/#findComment-655289 Share on other sites More sharing options...
.josh Posted October 2, 2008 Share Posted October 2, 2008 Are you supposed to have multiple options ($display), and only one table ($tblname)? Make $tblname the option name and the $display the option value. Quote Link to comment https://forums.phpfreaks.com/topic/126695-solved-passing-variables/#findComment-655307 Share on other sites More sharing options...
phatgreenbuds Posted October 2, 2008 Author Share Posted October 2, 2008 There is the value that is the actual table name and not exactly user-friendly something like blah_9_30_08. Then the correlating display to reference that table that is user-friendly like Sept 30th, 2008. Thus the two variables $tblname and $display. There are 14 of these combinations that can be selected and there is a new one added each day and an old one deleted everyday thru another automated script. In order to start using this I want to pass both variables to the next page. I can pass the one as the value but how would I pass the other which is traditionally a display name in the drop down? Is that even possible using a drop down? Quote Link to comment https://forums.phpfreaks.com/topic/126695-solved-passing-variables/#findComment-655877 Share on other sites More sharing options...
.josh Posted October 2, 2008 Share Posted October 2, 2008 hmm...if there's a different $tblname $display combo for each choice then only thing I can really think of is to first create a multidim array and pass a whole array as a value. Example: $data[0] = array ('tblname' => $tblname, 'display' => $display); . . . <option value = '{$data[0]}'>whatever</option> Quote Link to comment https://forums.phpfreaks.com/topic/126695-solved-passing-variables/#findComment-655914 Share on other sites More sharing options...
phatgreenbuds Posted October 2, 2008 Author Share Posted October 2, 2008 ok thats interesting...never would have thought to do it that way. I will try it tonight. Quote Link to comment https://forums.phpfreaks.com/topic/126695-solved-passing-variables/#findComment-655921 Share on other sites More sharing options...
DeanWhitehouse Posted October 2, 2008 Share Posted October 2, 2008 <?php $_PHP_SELF ?> should be <?php echo $_SERVER['PHP_SELF']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/126695-solved-passing-variables/#findComment-655976 Share on other sites More sharing options...
phatgreenbuds Posted October 4, 2008 Author Share Posted October 4, 2008 I was able to solve this by changing from POST to GET variables. Thanks for the suggestions guys. Quote Link to comment https://forums.phpfreaks.com/topic/126695-solved-passing-variables/#findComment-657124 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.