Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'koneksi.php';
- $server = "localhost";
- $user = "root";
- $password = "";
- $database = "rapatpcc";
- mysql_connect($server, $user, $password) or die ("Koneksi Putus");
- mysql_select_db($database) or die ("Database tidak bisa dibuka");
- if(isset($_POST['id_rapat']) && isset($_POST['id_user'])) {
- $id_rapat = $_POST['id_rapat'];
- $id_user = $_POST['id_user'];
- $sql = mysql_query("SELECT * FROM `kehadiran` WHERE id_rapat = $id_rapat ORDER BY `kehadiran`.`id_hadir` DESC ");
- $cek = mysql_num_rows($sql);
- $response = array();
- $sql2 = mysql_query("SELECT * FROM `kehadiran` WHERE id_user = $id_user");
- $cek2 = mysql_num_rows($sql2);
- $response2 = array();
- if($cek > 0 && $cek2 > 0){
- $response["hadir"] = array();
- while($row = mysql_fetch_array($sql)){
- $data = array();
- $data["id_hadir"] = $row["id_hadir"];
- $data["id_rapat"] = $row["id_rapat"];
- $data["nama_hadir"] = $row["nama_hadir"];
- $data["status_hadir"] = $row["status_hadir"];
- $data["ket_hadir"] = $row["ket_hadir"];
- $data["id_user"] = $row["id_user"];
- array_push($response["hadir"], $data);
- }
- $response["data"] = array();
- while($row = mysql_fetch_array($sql2)){
- $data = array();
- $data["id_hadir"] = $row["id_hadir"];
- $data["id_rapat"] = $row["id_rapat"];
- $data["nama_hadir"] = $row["nama_hadir"];
- $data["status_hadir"] = $row["status_hadir"];
- $data["ket_hadir"] = $row["ket_hadir"];
- $data["id_user"] = $row["id_user"];
- array_push($response["data"], $data);
- }
- $response["sukses"] = true;
- $response["pesan"] = "Berhasil mengambil data";
- echo json_encode($response);
- }else if ($cek > 0 && !$cek2 > 0){
- $response["hadir"] = array();
- while($row = mysql_fetch_array($sql)){
- $data = array();
- $data["id_hadir"] = $row["id_hadir"];
- $data["id_rapat"] = $row["id_rapat"];
- $data["nama_hadir"] = $row["nama_hadir"];
- $data["status_hadir"] = $row["status_hadir"];
- $data["ket_hadir"] = $row["ket_hadir"];
- $data["id_user"] = $row["id_user"];
- array_push($response["hadir"], $data);
- }
- $sql3 = mysql_query("INSERT INTO `kehadiran` (`id_hadir`, `id_rapat`, `id_user`) VALUES (NULL, $id_rapat, $id_user)");
- $response["sukses"] = true;
- $response["pesan"] = "Belum Konfirmasi Kehadiran";
- echo json_encode($response);
- } else {
- $response["sukses"] = false;
- $response["pesan"] = "Gagal mengambil data";
- echo json_encode($response);
- }
- } else {
- $response["sukses"] = false;
- $response["pesan"] = "Input Tidak ada";
- echo json_encode($response);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement