我正在處理的項目基本上涉及輸入框並將它們存儲到mysql數據庫中。我試圖使用JavaScript來生成此表單,如果需要可以添加另一個表單。我想我遇到的問題是讓它爲第二個生成的表單分配一個不同的「名稱」。 ex紅色,red1,red2等。然後也試圖讓這個與php-mysqli一起工作。多次生成相同的輸入
到目前爲止,我已經能夠將它發佈到表格中,但它將值發佈在第二組輸入框中。 有人可以提供一些建議嗎?
<form id="color_form" action="postcolors.php" method="post">
<input id="name" class="color_entry" action="postcolors.php" method="post" name="name" placeholder="song name" style="background-image: url("data:image/png;base64,iVBORw0KGgoAAAA…nt: scroll; background-position: right center; cursor: auto;"></input>
<input id="red" class="color_entry" action="" method="post" name="red" placeholder="red"></input>
<input id="green" class="color_entry" action="" method="post" name="green" placeholder="green"></input>
<input id="blue" class="color_entry" action="" method="post" name="blue" placeholder="blue"></input>
<input id="color" class="color_entry" action="" method="post" name="color" placeholder="color"></input>
<input id="name" class="color_entry" action="postcolors.php" method="post" name="name" placeholder="song name"></input>
<input id="red" class="color_entry" action="" method="post" name="red" placeholder="red"></input>
<input id="green" class="color_entry" action="" method="post" name="green" placeholder="green"></input>
<input id="blue" class="color_entry" action="" method="post" name="blue" placeholder="blue"></input>
<input id="color" class="color_entry" action="" method="post" name="color" placeholder="color"></input>
<input type="submit" value="submit" action="postcolors.php" method="post"></input>
</form>
$song=mysqli_real_escape_string($connect, $_POST['name']);
$song = str_replace(' ', '', $song);
mysqli_query($connect, "CREATE TABLE $song (id int(4) NOT NULL auto_increment, red int(2) NOT NULL, green int(2) NOT NULL, blue int(2) NOT NULL, color varchar(30) NOT NULL, index(id))");
$red=mysqli_real_escape_string($connect, $_POST['red']);
$green=mysqli_real_escape_string($connect, $_POST['green']);
$blue=mysqli_real_escape_string($connect, $_POST['blue']);
$color=mysqli_real_escape_string($connect, $_POST['color']);
mysqli_query($connect, "INSERT INTO $song (red,green,blue,color) VALUES ('$red', '$green', '$blue', '$color')");
您不能重複ID,ID =「名稱」只能在頁面中出現一次。 – Fahad 2014-10-17 11:38:15