Jump to content

Query leaving out spaces


sunsfan

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/242369-query-leaving-out-spaces/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.