简体   繁体   中英

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

My Table have column, column and column 列, 列和
I want insert data before "|" and after "|" on different columns, example i'm input this value to textarea :

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

Will insert to column , to column and to column 插入列插入列 to column
I Have this code from index.php :

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

File api.php :

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

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


Thanks everybody !

You can use explode to break using a separator |

$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);

Output

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

Now you can use array key 0 -> tap , 1 -> link , 2 -> player

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM