<?php include "model/_crud.mysqli.oop.php"; $crud = new CRUD("localhost", "root", "", "restoran"); $keterangan = @$_POST['keterangan']; $no = @$_POST['id']; $nama = @$_POST['nama']; $gambar = @$_FILES['gambar']['tmp_name']; $target = 'tampilan/img/'; $harga = @$_POST['harga']; $nama_gambar = @$_FILES['gambar']['name']; $pindah = move_uploaded_file($gambar, $target . $nama_gambar); if ($pindah) { $data = array('nama' => $nama, 'gambar' => $nama_gambar, 'harga' => $harga, 'keterangan' => $keterangan); $crud->update("makanan", $data, "no = '{$no}'"); header('location:admin.php'); } else { ?> <script type="text/javascript"> alert('gambar gagal di upload'); </script> <?php echo "ada yang salah"; }
<?php // TACOPS for CRUD include 'crud.php'; session_start(); $requests = $_POST; $CRUD = new CRUD(); foreach ($requests as $request) { if ($request['type'] == 'read') { $query = $request['query']; $result = $CRUD->read($query); } if ($request['type'] == 'create') { $query = $request['query']; $result = $CRUD->create($query); } if ($request['type'] == 'update') { $query = $request['query']; $result = $CRUD->update($query); } echo $result; }