簡體   English   中英

如何使用“|”字符將Textarea中的值插入數據庫?

[英]How To Insert Value From Textarea To Database With “|” Characters?

我的表tapphimtap列, 鏈接列和播放器
我想在“|”之前插入數據 並在“|”之后 在不同的列上,例如我將此值輸入到textarea:

1|fuuka-vietsub|https://drive.google.com/file/d/1tDKPbZ_gaNZrcYHt-tQtcF-TH0hMzGFi/view?usp=sharing

1插入列點擊fuuka-vietsub插入列鏈接https://drive.google.com/file/d/1tDKPbZ_gaNZrcYHt-tQtcF-TH0hMzGFi/view?usp=sharing to column player
我有來自index.php的代碼:

<form action="api.php" method="post">
<textarea name="themphim" id="themphim"></textarea>
<input type="submit" name="save" value="save"></input>
</form>

文件api.php:

<?php
include("db_connect.php");

if(isset($_POST['save']))
{
// Please give for me code
... 
//
}
?>


謝謝大家 !

您可以使用explode來分解使用分隔符

$string = '1|fuuka-vietsub|https://drive.google.com/file/d/1tDKPbZ_gaNZrcYHt-tQtcF-TH0hMzGFi/view?usp=sharing';
$strToArray = explode('|',$string);
echo '<pre>';
print_r($strToArray);

產量

Array
(
 [0] => 1
 [1] => fuuka-vietsub
 [2] => https://drive.google.com/file/d/1tDKPbZ_gaNZrcYHt-tQtcF-TH0hMzGFi/view?usp=sharing
)

現在你可以使用數組鍵0 -> tap1 -> link2 -> player

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM