text box only displaying one word as value

2019-08-05 02:29发布

问题:

Can anyone help me understand why a text box won't display a whole string opposed to just the first word? For example if the value of Name is "John Smith", the text box will display "John"

echo "<td>" . "<input type = text name = name value =" . $record['Name'] . " </td>" ;

回答1:

Thats because you did not quote your attribute value, without quotes spaces terminate the attribute value

echo "<td><input type = text name = name value =\"" . $record['Name'] . "\" ></td>" ;