簡體   English   中英

如何使用codeiginter從動態創建的表中的數據庫中獲取數據

[英]how to fetch the data from database in dynamically created table using codeiginter

<table class="table table-bordered table-striped table-xxs" id="tb3" name="tb3">
    <thead>
        <tr>
            <th><a href="javascript:void(0);" id="multi" name="multiplerows" title="Add More Person"></a></th>
            <th>Product Code</th>
            <th>Product Name</th>
            <th>Qty</th>
            <th>Rate</th>
            <th>Amount</th>


        </tr>
    </thead>
    <tbody>
        <tr >
            <td><a href='javascript:void(0);' class='remove3'><span class='glyphicon glyphicon-remove'></span></a></td>

            <td>

            <input style="width:80px" type="text" id="Product_Code"  class="form-control input-xs Product_Code "  onkeyup="fetch()" value="<?php echo $r->Product_Code; ?>" name="Product_Code[]" required></td>

            <td ><input style="width:300px" type="text" id="Product_Name" class="form-control input-xs" value="<?php echo $r->Prdtname; ?>" name = "Prdtname[]"  value=""> </td>


            <td><input style="width:80px" type="text" id="Qty"  class="form-control input-xs"  value="<?php echo $r->Qty; ?>" name="Qty[]" required></td>

            <td><input style="width:100px" type="text" id="Rate"  class="form-control input-xs" value="<?php echo $r->rate; ?>" name="rate[]" required></td>

            <td><input style="width:150px" type="text" id="Value" class="form-control input-xs" value="<?php echo $r->amount; ?>" name="amount[]" ></td>


        <th><a href="javascript:void(0);" id="addMore3" name= addmore title="Add More Person"><span class="glyphicon glyphicon-plus"></span></a></th>

        </tr>
    </tbody>
</table>

這個表代碼....

<script>
$(document).ready(function (){
$('#addMore3').on('click', function() {

  var data = $("#tb3 tr:eq(1)").clone(true).appendTo("#tb3");
          data.find("input").val('');

 });
 $(document).on('click', '.remove3', function() {
     var trIndex = $(this).closest("tr").index();
        if(trIndex>0) {
         $(this).closest("tr").remove();
       } else {
         alert("Sorry!! Can't remove first row!");
       }
  });

});

</script>

這是用於通過單擊“+”事件創建表格的 javascript 代碼。

我的prblm是如何從這個自動表中的數據庫顯示中獲取數據..

您應該能夠使用 ajax 調用來做到這一點。

當您使用 codeigniter 時 -

查看:編寫您的 ajax 和表生成代碼。 控制器:獲取ajax請求並將其傳遞給模態。 Modal:從數據庫中獲取數據。

您應該返回要查看的對象數組,然后解析數據並生成表。 如果你不想寫表代碼和ajax,那么你可以使用數據表插件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM