I want to create a variable that contains the data from one of the tables created by using foreach in PHP, using CodeIgniter. tersebuat variables would I use to see the detail of the data from the database which I will show in the form of pop up.
<table class="table table-striped table-bordered table-hover" id="ab">
<thead>
<tr>
<th> # </th>
<th> Invoice </th>
<th> Product </th>
<th> date </th>
<th> suplier </th>
<th> Description </th>
<th> Detail </th>
</tr>
</thead>
<tbody>
<?php $numb=0;foreach($proses as $isi){$numb++; ?>
<tr>
<td> <?php echo $numb;?> </td>
<td> <?php echo $isi->invoice;?> </td>
<td> <?php echo $isi->name;?> </td>
<td> <?php echo $isi->date;?> </td>
<td> <?php echo $suplier;?> </td>
<td> --- </td>
<td class="text-center">
<a class="btn blue btn-outline sbold" data-toggle="modal" href="#full"> Detail </a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
sample output from the program :
1|000012|Noodle|03-Mar-2016|Suplier01|--|(Detail)|
2|000044|Rice |05-Mar-2016|Suplier03|--|(Detail)|
How to enter an invoice number 000012
into a variable (eg, $invoice
) on click by invoice details
?
答案 0 :(得分:0)
我假设您希望将详细信息显示在模态中。
为此,您可以:
对于2,例如:
<a data-invoice="<?php echo $isi->invoice;?>" class="btn blue btn-outline sbold" data-toggle="modal" href="#full"> Detail </a>
然后使用jquery检测按钮点击并设置模态的html值。
$('a.btn').click(function(){
$('.modal <your own selector here>').html($(this).data('invoice'));
});