I am getting data from a database and which is used to populate the select element (list) on my page.
The data stored with which it has two spaces in my DB: "ABC CDE".
When I put the value in the select list, it removes the other space, thus leaving it "ABC CDE". But every time I get the data and I log it, it still has two spaces.
The problem is that if I needlook up something in DB using the name does not return anything because of the difference in spaces.
$query = "SELECT * from Member.people";
$logger->debug($query);
$result = mysql_query($query);
$num = mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
$op = $row['Name']; //ABC DE
echo '<option>'.$op.'</option>'; //ABC DE
}
can someone help?
Consecutive white spaces in HTML are collapsed:
They are preserved in attributes though. You have to set the
valueattribute correctly and it will work:If you don’t do that the content of the elements is used as value:
what, as you already noticed, will give you the value with only one space (as it is collapsed).