mysql テーブルのフィールドからリストを生成する php コードがあります。情報を別のデータベースに送信すると、スペースの後に何も表示されません - 最初の単語だけです (たとえば、ドロップダウンから「ローブ スポット」を選択し、「ローブ」のみがデータベースに挿入されます)。
これが私の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
?>
データベースに再送信するときにスペースを許可する正しいコードを探しています
ありがとうございました