sunsfan Posted July 19, 2011 Share Posted July 19, 2011 Fairly new to writing MYSQL in php so please forgive me if I make no sense. I am querying a MYSQL database to populate a dropdown menu. Form is get method on submit. The query populates the items in the dropsdown fine, and I use that same variable for the value for the get variable. But when the get variable is used one the url it leaves out everything after the first space. An example would be: I have a varchar field with "United States" as the data. In the dropdown menu it show "United States" just find, but when that field is selected and the submit button clicked, the url ends like this: "?country=United", the "states" part in missing. Below is some of my code. Thanks for the help $modequery="SELECT DISTINCT COL_MODE FROM table_hrd_contacts_v01 ORDER BY COL_MODE DESC"; /* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */ $moderesult = mysql_query ($modequery); echo "<select name=filtermode value=''>Mode</option>"; // printing the list box select command echo "<option value=>All Modes</option>"; while($ntmode=mysql_fetch_array($moderesult)){//Array or records stored in $nt if($filtermode == $ntmode[COL_MODE]){ echo "<option selected value='$filtermode'>$filtermode</option>"; } else { echo "<option value=$ntmode[COL_MODE]>$ntmode[COL_MODE]</option>"; } /* Option values are added by looping through the array */ } echo "</select>";// Closing of list box Quote Link to comment https://forums.phpfreaks.com/topic/242369-query-leaving-out-spaces/ Share on other sites More sharing options...
AyKay47 Posted July 19, 2011 Share Posted July 19, 2011 you cannot have spaces in the url, you will need to encode these values using urlencode or rawurlencode or, better yet, change the method to POST Quote Link to comment https://forums.phpfreaks.com/topic/242369-query-leaving-out-spaces/#findComment-1244852 Share on other sites More sharing options...
requinix Posted July 19, 2011 Share Posted July 19, 2011 The problem isn't the URL, it's the HTML. Because there aren't quotes the value stops at the first space. That has value=United. Add quotes. Like the s a few lines above. Quote Link to comment https://forums.phpfreaks.com/topic/242369-query-leaving-out-spaces/#findComment-1244865 Share on other sites More sharing options...
sunsfan Posted July 19, 2011 Author Share Posted July 19, 2011 The problem isn't the URL, it's the HTML. <option value=United States> Because there aren't quotes the value stops at the first space. That has value=United. Add quotes. Like the <option>s a few lines above. <option value='United States'> Thank you sir, that did the trick. Quote Link to comment https://forums.phpfreaks.com/topic/242369-query-leaving-out-spaces/#findComment-1244934 Share on other sites More sharing options...
AyKay47 Posted July 20, 2011 Share Posted July 20, 2011 i overlook the simple things sometimes... Quote Link to comment https://forums.phpfreaks.com/topic/242369-query-leaving-out-spaces/#findComment-1244965 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.