Kenapa bisa error gini

pesan error :mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, array given in C:\xampp\htdocs\biodata\index.php on line 64

<?php

require 'function.php';
// koneksi ke database
$conn = mysqli_connect("localhost", "root", "", "biodata");

// ambil data dari tabel siswa / query data siswa
$result = mysqli_query($conn, "SELECT * FROM siswa");

if( isset($_POST["cari"]) ) {
	$result = cari($_POST["keyword"]);

?>
<!DOCTYPE html>

<html>
<head>
     <title>Halaman Admin</title>
</head>
<body>

<h1>Daftar Biodata</h1>

<a href="tambah.php">Tambah data siswa</a>
<br><br>

<form action="" method="post">

	<input type="text" name="keyword" size="30" autofocus="" placeholder="masukan keyword pencarian" autocomplete="off">
	<button type="submit" name="cari">Cari!</button>

</form>

<br>

<table border="1" cellpadding="10" cellspacing="0"

   <tr>
       <th>No.</th>
	   <th>Aksi</th>
	   <th>Nama</th>
	   <th>Tgl Lahir</th>
	   <th>Jenis Kelamin</th>
	   <th>Kelas</th>
	   <th>QRcode</th>
   </tr>

   <?php $i = 1; ?>
   <?php while( $row = mysqli_fetch_assoc($result)): ?>

   <tr>
      <td><?= $i; ?></td>
	  <td>
	      <a href="ubah.php?id=<?= $row["id"]; ?>">ubah</a>
		  <a href="hapus.php?id=<?= $row["id"]; ?>" onclick=" return confirm('yakin?');">hapus</a>
	  </td>
	  <td><?= $row["nama"]; ?></td>
	  <td><?= $row["tgl"]; ?></td>
	  <td><?= $row["jeniskelamin"]; ?></td>
	  <td><?= $row["kelas"]; ?></td>
	  <td><?= $row["QRcode"]; ?></td>
    </tr>
	<?php $i++; ?>
	<?php endwhile; ?>

</table>

</body>
</html>

avatar Mextro
@Mextro

1 Kontribusi 0 Poin

Dipost 4 tahun yang lalu

Tanggapan

Untuk kurung penutup kurawal if pada baris 10 itu dimana yaa ?

isi fungsi cari() itu apa?

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban