Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML field truncating when Parsed 1

Status
Not open for further replies.

MikeAuz1979

Programmer
Aug 28, 2006
80
AU
Hi,

This may be a noob question so pls forgive.

Using PHP, Apache and MS_SQL2000 I have a page that has a text box, a select box and a submit button, this posts to another php file that then does a search using these parameters, the problem is that the select box's values have gaps and this field is being truncated to left of the first space when it arrives at the 2nd file. I tried post and get but to no avail.

An example is 'DVLA Team' is being truncated to 'DVLA'

I could convert any spaces to another set of characters and then re-convert back on this next page but I'm wondering if there's an easier in-built way to acheive this.

Thanks for any help
Mike

Input File
Code:
<body>
<form action="ADOSearchPost.php" method="Get">
</label>Client ID
<input type="text" name="ClientID" />

<label>Assigned to Team
<select name="Team" id="Team" maxlength = "50"><option value='' selected='selected'>Select...</option>
<?php
include('../adodb5/adodb.inc.php');

$db = ADONewConnection('odbc_mssql');
$db->Connect('Driver={SQL Server};Server=localhost;Database=fb34_Dims', 'sa', 'potty');
$rs = $db->execute("Select distinct assignedtoteam from customer");
while (!$rs->EOF) {
	$value = $rs->fields[0];
    print ("<option value= $value>$value</option>");
    $rs->MoveNext();  //  Moves to the next row
  }  // end while
php?>
</select>


<input type="submit" />
</form></body>
</html>

Searching File
Code:
<?php

include('../adodb5/adodb.inc.php');

echo $_GET['ClientID'];
echo $_GET['Team'];

//Other stuff....

//Search
 
Put quotes around your values.

If the variable $value holds the value "foo bar",then list line:

[tt]print ("<option value= $value>$value</option>");[/tt]

will output:

[tt]<option value= foo bar>foo bar</option>[/tt]

Most (if not all) browsers interpret spaces in tags to be attribute separators, but putting doublequotes around the values with spaces:

[tt]<option value="foo bar">foo bar</option>[/tt]

will make the browser recognize the entire value.

So the equivalent change to your print statement would be something like:

[tt]print ("<option value=\"$value\">$value</option>");[/tt]

or

[tt]print ('<option value="' . $value . '">$value</option>");[/tt]








Want to ask the best questions? Read Eric S. Raymond's essay "How To Ask Questions The Smart Way". TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top