Gimana cara mengatasi error tersebut mohon bantuannya kak

INVENTARIS ATTB 2019

Inventaris Data ATTB

<?php if(!empty($_GET['kosong'])) { if($_GET['kosong'] == 'data') { echo "

Data belum lengkap...

"; } } else if(!empty($_GET['simpan'])) { if($_GET['simpan'] == 'sukses') { echo "

Data berhasil disimpan...

"; } } ?>

<?php include "koneksi.php"; echo " Nomor Aset Nama Aset Lokasi Th. Perolehan/Bidang PIC QR Code "; $sql=$pdo->prepare("SELECT * FROM tb_barcode ORDER BY nomor"); $sql->execute(); $no=1; while($data=$sql->fetch()) { echo ""; echo "".$nomor.""; echo "".$nama.""; echo "".$lokasi.""; echo "".$tahun.""; echo "".$kodeqr.""; echo ""; $no++; } ?>
avatar Vinadw

@Vinadw

2 Kontribusi 0 Poin

  • bertanya dengan judul yang jelas, baca aturan main - @hilmanski


Jawaban Terpilih

<?php
$sql = mysqli_query($konek,"SELECT * FROM tb_barcode ORDER BY nomor");
while($data = mysqli_fetch_array($sql)){
	echo "<tr>";
		echo "<td>".$data['nomor']."</td>";
		echo "<td>".$data['nama']."</td>";
		echo "<td>".$data['lokasi']."</td>";
		echo "<td>".$data['tahun']."</td>";
		echo "<td>".$data['kodeqr']."</td>";

	echo "</tr>";
}
avatar driyan

@driyan

190 Kontribusi 108 Poin

Jawaban

$pdo belum didefisinikan, cek di koneksi.phpnya apakah nama variabelnya $pdo
avatar jeffian

@jeffian

26 Kontribusi 17 Poin

  • ini koneksi phpnya kak <?php $host="localhost"; $user="root"; $pass=""; $database='db_barcode'; $konek=mysqli_connect($host, $user, $pass) OR DIE (); mysqli_select_db($konek, $database) OR DIE (); ?> - @Vinadw
  • pdo gk bsa dicampur dengan mysqli gan - @jeffian
  • terus bagaimana? - @Vinadw

Tampikan semua |


kodingannya selectnya make pdo, tapi koneksinya make mysqli ???
avatar driyan

@driyan

190 Kontribusi 108 Poin

  • terus gimana kak caranya - @Vinadw
  • coba sertakan juga file koneksinya juga - @driyan
  • <?php $server='localhost'; $username='root'; $password=''; $database='barcode'; $konek=mysqli_connect($server,$username,$password) OR DIE (); mysqli_select_db($konek, $database) OR DIE (); ?> - @Vinadw


<?php
$sql = mysqli_query($konek,"SELECT * FROM tb_barcode ORDER BY nomor");
while($data = mysqli_fetch_array($sql)){
	echo "<tr>";
		echo "<td>".$data['nomor']."</td>";
		echo "<td>".$data['nama']."</td>";
		echo "<td>".$data['lokasi']."</td>";
		echo "<td>".$data['tahun']."</td>";
		echo "<td>".$data['kodeqr']."</td>";

	echo "</tr>";
}
avatar driyan

@driyan

190 Kontribusi 108 Poin


Login untuk gabung berdiskusi