我有一个 php 代码,它从 mysql 表中的字段生成一个列表。当我将信息提交到另一个数据库时,它在空格之后不显示任何内容 - 仅显示第一个单词(例如,如果我从下拉列表中选择“长袍点”并且仅将“长袍”插入数据库中)
这是我的php代码:
<?
$dbHost = 'localhost'; // localhost will be used in most cases
// set these to your mysql database username and password.
$dbUser = 'user';
$dbPass = 'pass';
$dbDatabase = 'stock'; // the database you put the table into.
mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db("stock") or die(mysql_error());
$query="SELECT category FROM subcategory_table";
/* You can add order by clause to the sql statement if the names are to be displayed
in alphabetical order */
$result = mysql_query ($query);
echo "<select name='category'>";
// printing the list box select command
while($nt=mysql_fetch_array($result)){//Array or records stored in $nt
echo "<option value=$nt[category]>$nt[category]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box
?>
我正在寻找正确的代码,以便在提交回数据库时允许空格
谢谢你