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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.