Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tws #114

Open
farhan695 opened this issue Jan 2, 2021 · 1 comment
Open

Tws #114

farhan695 opened this issue Jan 2, 2021 · 1 comment

Comments

@farhan695
Copy link

Pertemuan 14

@farhan695
Copy link
Author

Pertemuan 14

Koneksi Mysqli Error : " .mysqli_connect_error()); mysqli_select_db($con, $database) or die("

Koneksi Kedatabase Error :

" . mysqli_error($con)); @$operasi = $_GET['operasi']; switch ($operasi) { case "view"; $query_tampil_biodata = mysqli_query($con,"SELECT * FROM isibiodata") or die (mysqli_error($con)); $data_array = array(); while($data = mysqli_fetch_assoc($query_tampil_biodata)) { $data_array[]=$data; } echo json_encode($data_array); break; case "insert"; @$nim = $_GET['nim']; @$nama = $_GET['nama']; @$alamat = $_GET['alamat']; $query_insert_data = mysqli_query($con, "INSERT INTO isibiodata (nim, nama, alamat) VALUES('$nim','$nama','$alamat')"); if ($query_insert_data) { echo "Data Berhasil Disimpan"; } else { echo "Maaf Insert Ke Dalam Database Error" . mysqli_error($con); } break; case "get_biodata_by_id"; @$id =(int)$_GET['id']; $query_tampil_biodata = mysqli_query($con, "SELECT * FROM isibiodata WHERE id='$id'") or die (mysqli_error($con)); $data_array = array(); $data_array = mysqli_fetch_assoc($query_tampil_biodata); echo "[" .json_encode ($data_array) . "]"; break; case "update"; @$nim = $_GET['nim']; @$nama = $_GET['nama']; @$alamat = $_GET['alamat']; @$id = $_GET['id']; $query_update_biodata = mysqli_query($con, "UPDATE isibiodata SET nim = '$nim', nama='$nama', alamat='$alamat' WHERE id='$id'"); If ($query_update_biodata) { echo " Update Data Berhasil "; } else { echo mysqli_error($con); } break; case "delete": @$id = $_GET['id']; $query_delete_biodata = mysqli_query($con, "DELETE FROM isibiodata WHERE id='$id'"); if ($query_delete_biodata) { echo "Data Berhasil Dihapus"; } else { echo mysqli_error($con); } break; default; break; } ?>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant