如何在php的文本框中显示带有空格的整个变量 [英] how to display the entire variable with space in textbox in php
问题描述
我想在文本框中显示带有空格的值.数据库值是usman road".但是在文本框中它只显示usman".
I want to display the value with space in text box.database value is "usman road". But in text box it shows only "usman".
$value="select * from employee where e_id=$ses";
$value1=mysql_query($value);
$vfet=mysql_fetch_assoc($value1);
echo '<p>First Name<input type="text" name="f" size=18 maxlength=50 style="background-color:transparent;border:0px solid white;" readonly value='.$vfet['e_first_name'].'></p>';
推荐答案
在 value 周围加上引号
Put quotes around value
... value="'.$vfet['e_first_name'].'"...
您拥有的是无效的 html 并破坏了空间上的值
What you have is is invalid html and breaks the value on the space
... value='.$vfet['e_first_name'].' ... // value = john doe
^
修改后会变成
value = "john doe"
要对属性使用不带引号的值,您必须遵循以下 HTML 规范
To use unquoted value for attributes you have to follow the following HTML specifications
未加引号的属性值通过提供以下内容来指定部分完全按照以下顺序:
An unquoted attribute value is specified by providing the following parts in exactly the following order:
1.一个属性名
2. 零个或多个空格字符
2.zero or more space characters
3.单个=";字符
4. 零个或多个空格字符
4.zero or more space characters
5.一个属性值
除了对属性值的一般要求之外,还有一个未加引号的属性值有以下限制:
In addition to the general requirements for attribute values, an unquoted attribute value has the following restrictions:
• 不得 >包含任何文字空格字符
• must not > contain any literal space characters
• 不得包含任何"、"、>="、>"、<"或`",字符
• must not contain any """, "'",> "=", ">", "<", or "`", characters
不能是空字符串
因为你的值有一个空格,它违反了规则:)
Since your value has a space, it breaks the rules :)
这篇关于如何在php的文本框中显示带有空格的整个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!