繁体   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