如何使用modal boostrep twitter基于ID显示数据库中的详细数据,请将其设为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>
答案 0 :(得分:0)
将用户名列更新为
<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>