swilkins
06-08-2006, 04:24 PM
I am just learning PHP and MySql. I have a page that creates drop down boxes in a form by readng MySql databases. The box and all it's values look fine, but the $_POST variable that is passed when the form is submitted leaves off any data after a space.
**Any variables not defined in the following section are defined elsewhere in the code and are not causing any problems**
Ex:
echo "<SELECT NAME='ormpo' SIZE='1'><OPTION VALUE='all'>All PO Numbers";
$query = "SELECT ormpo from orm ORDER BY ormpo";
$result = mysql_query($query);
$lastpo='';
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
if ($lastpo != $row['ormpo'])
{
echo '<OPTION VALUE='.$row['ormpo'].'';
if ($row['ormpo'] != $ormpofilter)
{
echo '>'.$row['ormpo'].':'.$_POST['ormpo'].'';
}
else
{
echo ' SELECTED>'.$row['ormpo'].':'.$_POST['ormpo'].'';
}
$lastpo = $row['ormpo'];
}
}
echo "</SELECT>";
Some of the variables are numbers, some letters and some include spaces:
Ex: 17364976
SURFACES
ATTN MARY
If one of the items without spaces is chosen, I use the $_POST['ormpo'] to set a cookie and they work fine, If the example: ATTN MARY is chosen the $_POST['ormpo'] variable and the cookie contain only ATTN.
In MySql the ormpo field is set as tinytext (I also have tried varchar - neither works).
I feel like there is something stupid that I am missing, but I have been looking at this for two days and can't find anything!
I thought about removing the space, but can't find a function to do that.
Any help will be greatly appreciated.
Susan
**Any variables not defined in the following section are defined elsewhere in the code and are not causing any problems**
Ex:
echo "<SELECT NAME='ormpo' SIZE='1'><OPTION VALUE='all'>All PO Numbers";
$query = "SELECT ormpo from orm ORDER BY ormpo";
$result = mysql_query($query);
$lastpo='';
while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
if ($lastpo != $row['ormpo'])
{
echo '<OPTION VALUE='.$row['ormpo'].'';
if ($row['ormpo'] != $ormpofilter)
{
echo '>'.$row['ormpo'].':'.$_POST['ormpo'].'';
}
else
{
echo ' SELECTED>'.$row['ormpo'].':'.$_POST['ormpo'].'';
}
$lastpo = $row['ormpo'];
}
}
echo "</SELECT>";
Some of the variables are numbers, some letters and some include spaces:
Ex: 17364976
SURFACES
ATTN MARY
If one of the items without spaces is chosen, I use the $_POST['ormpo'] to set a cookie and they work fine, If the example: ATTN MARY is chosen the $_POST['ormpo'] variable and the cookie contain only ATTN.
In MySql the ormpo field is set as tinytext (I also have tried varchar - neither works).
I feel like there is something stupid that I am missing, but I have been looking at this for two days and can't find anything!
I thought about removing the space, but can't find a function to do that.
Any help will be greatly appreciated.
Susan