multiple insert textarea with php

335 views Asked by At

I cannot input data in the table mysql. I mean for this code use to insert multiple data textarea in mysql using php, I'm using wordpress so I should use prefix or please give me another code that works. I usually enter the data more than 20 in a textarea with a few words in one row if too much data is also affected

Sample data :

Ivan [email protected] 7612410 ivan 1234qwerty BCA 564649784645 ivan 81598686546 .com

Ivan    [email protected] 7612411 ivan 1234qwerty  BCA 564649784645 ivan 81598686546 .com

Ivan    [email protected] 7612412 ivan 1234qwerty  BCA 564649784645 ivan 81598686546 .com

Ivan    [email protected] 7612413 ivan 1234qwerty  BCA 564649784645 ivan 81598686546 .com

Ivan    [email protected] 7612414 ivan 1234qwerty  BCA 564649784645 ivan 81598686546 .com

Ivan    [email protected] 7612415 ivan 1234qwerty  BCA 564649784645 ivan 81598686546 .com

Ivan    [email protected] 7612416 ivan 1234qwerty  BCA 564649784645 ivan 81598686546 .com

Ivan    [email protected] 7612417 ivan 1234qwerty  BCA 564649784645 ivan 81598686546 .com

<form class="form-horizontal" role="form" method="post">

  <div class="form-group" id="rekowner">
    <label for="rekowner" class="col-lg-1 control-label">Pemilik Rekening</label>
    <div class="col-lg-8">
      <textarea rows="30" cols="700" name="list"></textarea>
    </div>
  </div>  

  <div class="form-group">
    <center>
      <button class="button button-primary" onClick="return confirm('Anda sudah yakin akan menyimpannya?');">Simpan</button>
    </center>
    <p>&nbsp;</p>
  </div>
  
</form>

if($_POST['list']) {
    $list = explode("\n",$_POST['list']);
    $i=0;
    foreach($list as $data) {
        $data = str_replace("\t"," ",$data);
        $data = @explode(" ",$data);
        $nama = trim($data[0]);
        $email = trim($data[1]);
        $insta_no = trim($data[2]);
        $insta_nama = trim($data[3]);
        $phone_pass = trim($data[4]);
        $bank_nama = trim($data[5]);
        $bank_rekening = trim($data[6]);
        $bank_pemilik = trim($data[7]);
        $no_hp = trim($data[8]);
        $group = trim($data[9]);

$wpdb->insert($wpdb->prefix."datamember",
    array(
    "insta_no"=>$insta_no,
    "nama"=>$nama,
    "email"=>$email,
    "insta_no"=>$insta_no,
    "insta_nama"=>$insta_nama,
    "phone_pass"=>$phone_pass,
    "nama_bank"=>$bank_nama,
    "bank_rekening"=>$bank_rekening,
    "bank_pemilik"=>$bank_pemilik,
    "no_hp"=>$no_hp,
    "group"=>$group
    ));
        $i++;
    };
    ?>
1

There are 1 answers

0
Amjath Khan On

<form class="form-horizontal" role="form" method="post">

  <div class="form-group" id="rekowner">
    <label for="rekowner" class="col-lg-1 control-label">Pemilik Rekening</label>
    <div class="col-lg-8">
      <textarea rows="30" cols="700" name="list"></textarea>
    </div>
  </div>  

  <div class="form-group">
    <center>
      <button class="button button-primary" onClick="return confirm('Anda sudah yakin akan menyimpannya?');">Simpan</button>
    </center>
    <p>&nbsp;</p>
  </div>
  
</form>