<?php
include 'koneksi.php';
$query = mysqli_query($koneksi, "SELECT DISTINCT(CONCAT(nama_pelanggan, handphone))
AS kunci, nama_pelanggan, handphone, tanggal FROM kuesioner ORDER BY id_kuesioner, id_pernyataan");
$no = 1;
$sim = array('0812', '0813', '0819', '0853', '0878', '0896', '0857', '0811');
while($result = mysqli_fetch_array($query)){
  $nama_pengguna = $result['nama_pelanggan'];
  // $handphone = $result['handphone'];
  // $handphone = str_replace("(+62)", "", $handphone);
  // //$handphone = str_replace($handphone, ")", "");
  // $handphone = str_replace(" ", "", $handphone);
  // $handphone = $sim[rand(0, 7)].$handphone;
  // $handphone = substr($handphone, 0, 12);
  // $password = '123';

  $query2 = mysqli_query($koneksi, "SELECT * FROM pengguna WHERE nama_pengguna='".$nama_pengguna."'");
  $result2 = mysqli_fetch_array($query2);
  $id_pengguna = $result2['id_pengguna'];

  $sql2 = "UPDATE kuesioner SET id_pengguna='".$id_pengguna."' WHERE nama_pelanggan='".$nama_pengguna."'";
  $result2 = mysqli_query($koneksi, $sql2);

  // $sql2 = "INSERT INTO pengguna(nama_pengguna, handphone, password)
  // VALUES('".$nama_pengguna."', '".$handphone."', '".$password."')";
  // $result2 = mysqli_query($koneksi, $sql2);
  $no++;
}
?>
