【问题标题】:How To Insert Value From Textarea To Database With "|" Characters?如何使用“|”将文本区域中的值插入数据库人物?
【发布时间】:2019-05-10 10:18:30
【问题描述】:

我的表 tapphimtap 列、link 列和 player
我想在“|”之前插入数据在“|”之后在不同的列上,例如我将此值输入到 textarea :

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

1 插入 tap 列,fuuka-vietsub 插入 link 列和 @987654321 @玩家
我有来自 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
... 
//
}
?>


谢谢大家!

【问题讨论】:

    标签: php insert textarea


    【解决方案1】:

    您可以使用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 -&gt; tap1 -&gt; link2 -&gt; player

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-29
      • 2023-04-02
      • 1970-01-01
      • 2014-04-28
      • 1970-01-01
      • 2021-11-15
      • 1970-01-01
      • 2017-09-27
      相关资源
      最近更新 更多