Hallo gan, mau nanya ini yang salah dari script ane yang mana yah ?
Ane mau setiap user kllik tombol "LIHAT" maka akan muncul modal yang berisi rincian dari anggota.
Spoiler for index.php :
Code:
<?php
$terhubung = mysqli_connect("localhost","root","","db_arisan");
$mantra = "SELECT * FROM tb_anggota";
$hasil = mysqli_query($terhubung, $mantra);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Pembukuan Arisan</title>
[removed][removed]
[removed][removed]
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
</head>
<body>
<br><br>
<div class="container" style="width:700px;">
<h3 align="Center">Data Anggota Arisan</h3>
<br>
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<th width="70%">Nama Anggota</th>
<th width="30%">Lihat Data</th>
</tr>
<?php
while ($baris = mysqli_fetch_array($hasil)) {
?>
<tr>
<td><?php echo $baris[1]; ?></td>
<td><input type="button" name="lihat" value="Lihat" id="<?php echo $baris["no_arisan"]; ?>" class="btn btn-info btn-xs lihat_data" /></td>
</tr>
<?php
}
?>
</table>
</div>
</div>
<h1>Kamu Pasti Bisa !! Semangat !!!</h1>
</body>
</html>
<div id="dataModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Rincian Anggota</h4>
</div>
<div class="modal-body" id="rincian-anggota">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Tutup</button>
</div>
</div>
</div>
</div>
[removed]
$(document).ready(function(){
$('.lihat_data').click(function(){
var no_arisanAGT = $(this).attr("");
$.ajax({
url:"pilih.php",
method:"POST",
data:{no_arisanAGT:no_arisanAGT},
success:function(data){
$('#rincian_anggota').html(data);
$('#dataModal').modal("show");
}
});
});
});
[removed]
Spoiler for pilih.php :
Code:
<?php
if (isset($_POST["no_arisanAGT"]))
{
$keluaran = '';
$terhubung = mysqli_connect("localhost","root","","db_arisan");
$mantra = "SELECT * FROM tb_anggota WHERE no_arisan = '".$_POST["no_arisanAGT"]."'";
$hasil = mysqli_query($terhubung, $mantra);
$keluaran .= '
<div class="table-responsive">
<table class ="table table-bordered">';
while ($baris = mysqli_fetch_array($hasil))
{
$keluaran .= '
<tr>
<td width="30%"><label>Nama</label></td>
<td width="70%">'.$baris[1].'</td>
</tr>
<tr>
<td width="30%"><label>Alamat</label></td>
<td width="70%">'.$baris[2].'</td>
</tr>
<tr>
<td width="30%"><label>No. Telepon</label></td>
<td width="70%">'.$baris[3].'</td>
</tr>
';
}
$keluaran .= "</table></div>";
echo $keluaran;
}
?>