嗨,你好,你有這個代碼,textarea提交到數據庫的一些想法。因爲我有一個connection.php,但它沒有插入數據庫,請幫助我使用選項textarea。你能不能幫我也phpMyAdmin的SQL什麼名稱,類型,等我應該把,謝謝錯誤插入PHP到數據庫使用jquery函數選項textarea
select.html
<html lang="en">
<title>NTF Catering Service</title>
<meta charset="utf-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<script src="js/js.1.js" type="text/javascript"></script>
</head>
<body>
<form action="submit.php" method="post">
<select multiple="multiple" name="food" class="options" id="textarea">
<option name="foodA"value="foodA">foodA</option>
<option name="foodB" value="foodB">foodB</option>
<option name="foodC" value="foodC">foodC</option>
<option name="foodD" value="foodD">foodD</option>
<option name="foodE" value="foodE">foodE</option>
</select>
<button type="button" id="copy" onclick="yourFunction()">Copy</button>
<button type="button" id="remove" onclick="yourFunction()">Remove</button>
<select id="textarea2" multiple class="remove" name="food">
<input type="submit" name="submit" />
</form>
</select>
</html>
connection.php
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$db = "copy";
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($db);
?>
提交.php
<?php
include 'connection.php';
$foodA = $_POST['foodA'];
$foodB = $_POST['foodB'];
$foodC = $_POST['foodC'];
$foodD = $_POST['foodD'];
$foodE = $_POST['foodE'];
if(!$_POST['submit']) {
echo "please fill out the form";
header('Location: select.html');
} else {
$sql = "INSERT INTO remove(food1, food2, food3, food4, food5) VALUES ('".$food1."', '".$food2."', '".$food3."','".$food4."','".$food5."');";
mysql_query($link, $sql);
echo "User has been added!";
header('Location: select.html');
}
?>
在選擇關閉之前,'select's需要名稱和表格正在關閉 –
@ G.Mendes tnx您的回覆,但我已經在名稱上,但仍未插入到db – user3211646
請更新代碼在選擇名稱中,'submit.php'中的'$ _POST'項必須與輸入中給出的名稱具有相同的名稱才能工作 –