How To Put Value Containing Spaces In Option Tag?
I need to assign a string to value in option tag, which contains multiple words. echo '' ; I tried it like this, but only one
Solution 1:
The HTML attributes are separated by spaces. To specify a value, which contains spaces you need to enclose it in quotes, either single '
or double "
.
<optionvalue="some value"anotherAttribute=1></option>
Becuase in PHP you have already used double quotes you can use single quotes now to enclose the value of your HTML attribute.
echo"<option value='".$row['code']."' ></option>" ;
You could also put the value between the tags as the content, if the value and the displayed content is the same.
echo"<option>".$row['code']."</option>" ;
Post a Comment for "How To Put Value Containing Spaces In Option Tag?"