Postingan lainnya
cara menampilkan data di modal bootstrap
bagaimana yah cara supaya bisa nampilin data dari tabel ke modal bootstrap, data yang muncul itu per baris menurut id nya masing2 ketika di klik ....
<table class="table table-datatable table-custom" id="basicDataTable">
<?php
// includekan fungsi paginasi
include 'pagination1.php';
// koneksi ke database
include 'conection.php';
// query
$id = $_GET['cp_cid'];
$sql = ("SELECT cp_cid,cp_mate,cp_hues,cp_width,cp_mode,cp_name,cp_unit,cp_cury,cp_pack,cp_price,cp_date,cp_weight,cp_cprice,cp_uprice,cp_temp FROM [cust_pric] LIMIT WHERE cp_flag=0 ");
$result = mssql_query($sql);
//pagination config start
$rpp = 8; // jumlah record per halaman
$reload = "page2.php?page = true";
$page =isset ($_GET['page']) ? intval ($_GET ['page']) :1;
if($page<=0) $page = 1;
$tcount = mssql_num_rows($result);
$tpages = isset($tcount) ? ceil($tcount/$rpp) : 1; // total pages, last page number
$count = 0;
$i = ($page-1)*$rpp;
$no_urut = ($page-1)*$rpp;
//pagination config end
?>
//modal
<div id="onphpidLogin" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<div class="modal-body">
<h4 class="modal-title">Detail information</h4>
<hr>
<div class="form-group">
<div class="modal-footer">
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<table class="table table-datatable table-custom" id="example">
<thead>
<tr>
<th>check</th>
<th>No</th>
<th class="no-sort" data-toggle="modal">Cp_Cid</th>
<th class="no-sort">Cp_Mate</th>
<th class="no-sort">Cp_Hues</th>
<th class="no-sort"><center>Cp_Width</center></th>
<th class="no-sort">Cp_Name</th>
<th class="no-sort">Cp_Unit</th>
<th class="no-sort">Cp_Cury</th>
<th class="no-sort"><center>Cp_Pack</center></th>
<th class="no-sort"><center>Cp_Price</center></th>
<th class="no-sort">Cp_Date</th>
<th class="no-sort">Cp_Weight</th>
<th class="no-sort">Cp_CPrice</th>
</tr>
</thead>
<tbody>
<?php
while(($count<$rpp) && ($i<$tcount)) {
mssql_data_seek($result,$i);
$data = mssql_fetch_array($result);
?>
<tr>
<td><center><input type="checkbox" value="1" <?php if($data['checkfield']=="1") echo "checked"; ?>></center></td>
<td ><center><?php echo ++$no_urut;?></center> </td>
<td type="submit" data-toggle="modal" data-target="#onphpidLogin"><?php echo $data['cp_cid']?></td>
<td type="submit" data-toggle="modal" data-target="#onphpidLogin"><?php echo $data['cp_mate']?></td>
<td type="submit" data-toggle="modal" data-target="#onphpidLogin"><?php echo $data['cp_hues']?></td>
<td><?php echo $data['cp_width']?></td>
<td type="submit" data-toggle="modal" data-target="#onphpidLogin"><?php echo $data['cp_name']?></td>
<td type="submit" data-toggle="modal" data-target="#onphpidLogin"><?php echo $data['cp_unit']?></td>
<td type="submit" data-toggle="modal" data-target="#onphpidLogin"><?php echo $data['cp_cury']?></td>
<td type="submit" data-toggle="modal" data-target="#onphpidLogin"><?php echo $data['cp_pack']?></td>
<td type="submit" data-toggle="modal" data-target="#onphpidLogin"><?php echo $data['cp_price']?></td>
<td type="submit" data-toggle="modal" data-target="#onphpidLogin"><?php echo $data['cp_date']?></td>
<td type="submit" data-toggle="modal" data-target="#onphpidLogin"><?php echo $data['cp_weight']?></td>
<td type="submit" data-toggle="modal" data-target="#onphpidLogin"> <?php echo $data['cp_cprice']?></td>
</td>
</tr>
<?php
$i++;
$count++;
}
?>
</tbody>
0
1 Jawaban:
Jawaban Terpilih
ada 2 cara :
-
Modalnya bisa di looping didalam <pre> while() </pre> dan data-targetnya diset menggunakan id masing2 data. Jadi ketika halaman diload, seluruh data akan langsung keluar.
-
Menggunakan jQuery AJAX. Jadi data tidak akan keluar langsung ketika halaman diload, tetapi hanya akan keluar ketika tombol modal di klik
Kodingannya gimana? Silahkan googling gan, banyak kok. Sy cuma sampaikan konsepnya aja.
1