Save data ke database dari while loop

tolong pencerahannya agan agan sekalian untuk memasukan data dari while loop php ke database.

<table class="table">
   <thead class="thead-dark">
     <tr>
       <th class="col-3">id</th>
       <th class="col-7">nama</th>
       <th class="col-3">rank</th>
     </tr>
   </thead>
   <tbody>
     <?php								$rank = 'A';
       $sql = "select t_empeval.id, t_empeval.nama from t_empeval Where t_empeval.grade='$c' and sect=CONCAT('$a','$b') order by t_empeval.v1 desc limit ".$var1."";
       $query = mysqli_query($koneksi, $sql);
       if(!$query)
       {
         die('SQL Error :' . mysqli_error($koneksi));
       }
       if(mysqli_num_rows($query) > 0)
       {
          while ($row = mysqli_fetch_array($query))
          {
             echo "<tr>";
             echo "<td>".$row['id']."</td>";
             echo "<td>".$row['nama']."</td>";
             echo "<td>".$rank."</td>";
             echo "</tr>";
          }
       }
     ?>
   </tbody>
</table>

diatas kode while loopnya. Sedangkan di bawah untuk submit ke database.

<?php
	include 'koneksi.php';
	if (isset($_POST['save'])) {
    $count = $_POST['count'];
    for ($i = 0; $i < $count; $i++) {
        $id = $_POST['id'][$i]; // check empty and check if interger
        $nama = $_POST['nama'][$i]; // check empty and strip tags
        $rank = $_POST['rank'][$i]; // check empty and check if interger

		echo $id;
		echo $nama;
		echo $rank;
    }
}
?>

sengaja tidak diinput, karna untuk test view ke dekstop, rupanya di echo saja tidak muncul.

avatar andrydupti
@andrydupti

6 Kontribusi 1 Poin

Dipost 3 tahun yang lalu

Tanggapan

Itu kenapa ga bikin form?

oh iya lupa diatas udah ada tag

gan

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban
id nama rank