sanem Posted May 11, 2023 Share Posted May 11, 2023 data store in db as same as table using party_id view :- <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" id="dtHorizontalExample" 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> controller :- 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'); } modeladmin :- function insertdata($tablename, $postdata){ $created_by = $this->session->userdata('admin_data'); $created_on = date('Y-m-d H:i:s'); $postdata['created_by'] = $created_by; $postdata['created_on'] = $created_on; if($this->db->insert($tablename, $postdata)) { return true; }else{ return false; } } Quote Link to comment Share on other sites More sharing options...
maxxd Posted May 11, 2023 Share Posted May 11, 2023 Do you have a question? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted May 11, 2023 Share Posted May 11, 2023 Yes - is there a question or at least something that explains what all the code is about. Quote Link to comment Share on other sites More sharing options...
sanem Posted May 11, 2023 Author Share Posted May 11, 2023 is not a solution plz try this code and tell me whats wrong this code Quote Link to comment Share on other sites More sharing options...
Barand Posted May 11, 2023 Share Posted May 11, 2023 The only place that the code has a chance of running is in your own environment. Are you expecting everyone to have a database with your tables and table structures, to name just one obstacle? 1 Quote Link to comment Share on other sites More sharing options...
maxxd Posted May 12, 2023 Share Posted May 12, 2023 Things you'll need to do to get help: Describe what the code should be doing Describe what the code is doing instead Show us any errors you're getting in your browser Show your relevant code If it seems like the error could be a database problem, describe the data and its structure Explain what you've done so far to fix the issue(s) Quote Link to comment Share on other sites More sharing options...
ginerjm Posted May 12, 2023 Share Posted May 12, 2023 What? Do you think that this is some kind of puzzle site where we all come together to guess what is happening? 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.