问题
Now i submit this to textarea :
1|Value
This insert to database :
-------------------
Column1 | Column2
1 | Value
-------------------
Now I want to add these results to multiple lines by pressing the enter key, please help me add it This is my HTML index code :
<form method="POST" action="add.php">
<div class="form-group">
<label for="chonphim">Film:</label>
<select class="form-control" name="chonphim" id="chonphim">
<option value="kono-yo-no-hate-de-koi-wo-utau-shoujo-yu-no_JZ93Q">Phim Kono Yo no Hate de Koi wo Utau Shoujo YU-NO</option>
</select>
</div>
<div class="form-group">
<label for="player">Multiple row and data:</label>
<textarea class="form-control" id="player" name="player" rows="4" placeholder="1|Value1
2|Value2
3|Value3"></textarea>
</div>
<center>
<div class="form-group">
<button style="margin-top: 15px;" class="btn btn-primary active" type="submit" >Add value</button></div></center>
</form>
This is add.php
$chonphim=$_POST['chonphims'];
$player = escape_string($_POST['player']);
$player1 = explode("|", $player);
$tapphim = $player1[0];
$linkplayphim = $player1[1];
$sql2 = "UPDATE vohuunhan_film SET settime = settime + 1 WHERE link = '$chonphim'";
$sql88 = "INSERT INTO vohuunhan_episode (tap, linkplay, id_film)
VALUES (N'$tapphim', N'$linkplayphim', N'$chonphim');";
if ($connect->query($sql88) === TRUE && $connect->query($sql2) === TRUE) {
echo "Success !";
} else {
echo "Error: " . $connect->error;
}
I want :
1|Value1
2|Value2
3|Value3
Insert to database :
-------------------
Column1 | Column2
1 | Value1
2 | Value2
3 | Value3
-------------------
来源:https://stackoverflow.com/questions/57015837/how-to-insert-multiple-value-and-multiple-rows-from-textarea-to-mysql-using-php