只显示多字变量中的第一个字 [英] Only first word In a multi word variable is being displayed
问题描述
在我的表单中,我有以下基于标准PHP / MySql查询的值。
echo< tr> \ n
< td align ='right'>< b> ;位置< / b>< / td>
< td>< input name ='student_location'type ='text'size = '25'style ='font-weight:700'value = $ location> ;< / td>
< / tr>;
当 $ location
的值为一个单词显示正确,当它不止一个单词说'North Campus'只显示'North'。
我已经加倍和三重检查,正确的值是在数据库中,当我为$ location的值做一个回声时,它会回应正确的值,但是当它显示在上面的字段中时,它会删除最后一个字。这对我所有的变量都是不止一个单词的做法,所以我错过了一些显而易见的东西。
引用: echo< tr> \ n
< td align ='right'><<< ; b>位置< / b>< / td>
< td>< input name ='student_location'type ='text'size = '25'style ='font-weight:700'value = \$ location \>< / td>
< / tr>;
如果没有引号,第一个单词会被记录下来,其他单词将被解释为错误的属性。 >
In my form I have the following values that are based on a standard PHP/MySql query.
echo "<tr>\n
<td align='right'><b>Location</b></td>
<td><input name='student_location' type='text' size='25' style='font-weight: 700' value=$location></td>
</tr>";
When the value of $location
is a single word it displays properly, when it is more than one word say 'North Campus' only 'North' displays.
I've doubled and triple checked and the correct value is in the database, when I do an echo for the value of $location it echoes the correct value but when it's displayed in the field above it chops the last word. It's doing it to all of my variables that are more than one word, so I've missed something obvious.
You forgot quotes :
echo "<tr>\n
<td align='right'><b>Location</b></td>
<td><input name='student_location' type='text' size='25' style='font-weight: 700' value=\"$location\"></td>
</tr>";
Without quotes, the first word will be noted, others will be interpreted as wrong attributes.
这篇关于只显示多字变量中的第一个字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!