JDPerry Posted April 18, 2006 Share Posted April 18, 2006 I am typing the code below to pass two variables from two selection boxes to a page titled "pass_test.php". The selection boxes are based on databases. When you look at the web page is displays propertlyand let users select the name and the empnum but when you hit the submit button it send value for the lastrow in each database. I am new to both PHP and HTML so I think it is something I have structure incorrectly. The link to the database works fine but my variable won't post. Any help would be appreciated.thanksJDPerry<html><center><?php//Get all the data from the "Period" Table$result = mysql_query("SELECT * FROM Period") or die (mysql_error());//Get data from the "UserInfo" Table$result2 = mysql_query("SELECT * FROM UserInfo ORDER BY Lname") or die (mysql_error());//Create a selection list for the UserInfo table echo "<select name = 'EmpNum'>\n";echo "<option value = '0'>Select a User\n";//Retreive data until all results collected from UserInfowhile($row = mysql_fetch_array($result2)) {extract($row);echo "<option value = $EmpNum>$Fname $Lname\n";}echo "</select>\n";echo "<br></br>";//Create a selection list for the Period table echo "<select name = 'PeriodID'>\n";echo "<option value = '0'>Select a Reporting Period\n";//Retreive data until all results collected from PERIODwhile($row = mysql_fetch_array($result)) {extract($row);echo"<option value = $PeriodID>$PeriodDesc\n";}echo "</select>\n";echo "<br></br>";print ("</TABLE>\n");print ("<form action=\"pass_test.php\" METHOD=\"POST\">\n");print ("<INPUT TYPE=\"hidden\" NAME=\"EmpNum\" VALUE=\"{$HTTP_POST_VARS['EmpNum']}\">\n");print ("<INPUT TYPE=\"hidden\" NAME=\"PeriodID\"VALUE=\"{$HTTP_POST_VARS['PeriodID']}\">\n");print ("<INPUT TYPE=\"submit\" VALUE=\"View Report\">\n");print ("</form>\n");print ("</CENTER>\n");?></center></html> Quote Link to comment Share on other sites More sharing options...
AndyB Posted April 19, 2006 Share Posted April 19, 2006 With that code both the dropdown selectors are generated outside your form and therefore 100% ineffective. What gets passed are the hidden values (and it's not clear what purpose that serves). Restructure your code to get the opening form tag before the dropdowns. 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.