surajkandukuri Posted October 1, 2009 Share Posted October 1, 2009 Hi All, I am new to php scripting and write now i am stuck with my coding. I have drop down box which gets its values from mysql database, I can see correct values in the drop down box, but the problem is I AM unable to store the value selected by the user in a variable. The code is attached below. $strQuery = "select * from employees"; $rsrcResult = mysql_query($strQuery); while($arrayRow = mysql_fetch_assoc($rsrcResult)) { $strA = $arrayRow["employee_id"]; $strB = $arrayRow["employeename"]; echo "<option selected='selected' value=\"$selectedvalue\">$strB</option>\n"; } Any help is really appreciated. Quote Link to comment Share on other sites More sharing options...
cags Posted October 1, 2009 Share Posted October 1, 2009 So you wish to store the selected value in a variable? In order to do that the form would need to be submitted (PHP is server side, so it can only see the selected value once you submit the information back to the server). You would then use either the $_POST or $_GET superglobal arrays to fetch the value based on the name attribute of the select node. Quote Link to comment Share on other sites More sharing options...
surajkandukuri Posted October 1, 2009 Author Share Posted October 1, 2009 Thank you Cags!! I tried submitting the Drop down box using POST method but once the page refreshes , Drop down box becomes empty with no values in it, and also I cannot ECHO the value selected using echo($selectedvalue). I have changed the value attribute of the above code to NAME attribute 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.