sanem Posted May 11, 2023 Share Posted May 11, 2023 (edited) hello everyone i want to help on this code i create table form i want to add product_name,party_name as same as add quntity in particular name simply way i add whole table in db <form action="<?php echo base_url(); ?>daily_orders/do_add" id="frmvalidate" method="post" role="form" enctype="multipart/form-data"> <div class="box-header"> <div class="row"> <div class="col-lg-2"> <input type="date" name="order_date" class="form-control" value="<?php echo date('Y-m-d'); ?>"> </div> </div> </div> <div class="box-body table-responsive"> <table class="table table-bordered table-condensed table-hover table-striped" width="1200px;"> <thead> <tr> <th style="color: #d81b60;"> Party Name \ Product Name</th> <?php foreach ($products as $key => $value) {?> <th> <input type="text" name="product_name[]" class="form-control" value="<?php echo $value['product_name'].' - '.$value['quantity'].' '.$value['unit_measurmrnt']; ?>" readonly> </th> <?php } ?> </tr> </thead> <tbody> <tr> <?php foreach ($party_master as $key => $value) {?> <tr> <th> <input type="text" name="party_name[]" class="form-control" value="<?php echo $value['party_name']; ?>" readonly> <input type="hidden" name="party_id[]" value="<?php echo $value['id']; ?>"> <?php foreach ($products as $key => $value1) { ?> <th><input type="text" name="quantity_<?php echo $value['id'] ?>_<?php echo $value1['id'] ?>" class="form-control" placeholder="quantity"></th> <input type="hidden" name="product_name_<?php echo $value['id'] ?>_<?php echo $value1['id'] ?>" value="<?php echo $value1['id']; ?>"> <?php } ?> </tr> <?php } ?> </tr> </tbody> </table> <div class="box-footer"> <button type="submit" class="btn bg-maroon btn-flat pull-right">Submit</button> </div> </div> </form> function do_add() { $cng=count($_POST['party_id']); for ($i=0; $i < $cng; $i++) { $cng1=count($_POST['product_name_'.$_POST['party_id'][$i]]); for ($m=0; $m < $cng1; $m++) { $insert_arr = array( 'party_id'=>$_POST['party_id'][$i], 'order_date'=>$_POST['order_date'], 'party_name'=>'', 'product_name'=>'', 'quantity'=>$_POST['quantity_'.$_POST['party_id'][$i]] ); print_r($insert_arr);die(); $this->modeladmin->insertdata("daily_orders",$insert_arr); } } redirect(base_url().'daily_orders'); } Edited May 11, 2023 by sanem Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.