![](/img/trans.png)
[英]How to save and display values from modal to view by database using codeigniter
[英]How to display the detailed data from the database using bootstrep modal codeigniter?
如何顯示基於ID的帶有模式boostrep twitter的數據庫中的詳細數據,請使其用於jquery或ajax代碼,以便在將詳細信息單擊到彈出模式中時顯示數據?
<tbody id="terakhir" >
<?php
$iw = $this->uri->segment(3) + 0;
foreach ($blogger as $i): $iw++;
?>
<tr >
<td>
<input type="text" class='nomor' id='<?php echo $iw; ?>'>
<input type="text" class='box' >
<?php echo $iw; ?></td>
<td>
<?php echo $i->username; ?>
</td>
<td class=lastName >
<?php
$date = strtotime($i->tanggal_register);
echo format_date($date, time()) . ' WIB';
?>
</td>
<td>Member</td>
<td>
<?php
if ($i->akses != "B"):
echo "<span class='label label-success'>Active</span>";
else:
echo "<span class='label label-important'>Blokir</span>";
endif;
?>
</td>
<td>
<a class="btn btn-danger" href="#">
<i class="fa fa-trash-o "></i>
</a>
<a href="#" class="btn tampil<?php echo $iw; ?>">Edit</a>
</td>
</tr>
<?php
endforeach;
?>
</tbody>
將用戶名列更新為
<td>
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal" value="<?php echo $i->username;?>"><?php echo $i->username; ?></button>
</td>
現在添加此JavaScript以調用模式並在ajax中加載數據
<script type="text/javascript">
$("#terakhir").on('click','button',function(event){
var username = $(this).val();
$.ajax({
type: 'POST',
url: "yourphpfile.php",
data:"username="+username,
success:function(data){
//print your data here in modal html elements
},
error:function(error){
alert(error);
}});
});
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.