Note that there are some explanatory texts on larger screens.

plurals
  1. POInserting multiple rows in database codeigniter
    primarykey
    data
    text
    <p>I have some issue about the inserting data. It will insert only the waybillno data but the quantity is always same. Please check my code - I think the model is wrong.</p> <h3>Controller</h3> <pre><code>public function create_cargo_manifest(){ $core_model = new Core_m; $core_model-&gt;save_cargo_details($this-&gt;input-&gt;post()); redirect('core/cargo_lookup/'); } </code></pre> <h3>Model</h3> <pre><code>function save_cargo_details(){ $quantity = $this-&gt;input-&gt;post('quantity'); $waybilldate = $this-&gt;input-&gt;post('waybilldate'); $data = array(); foreach($this-&gt;input-&gt;post('sys_wbdetails') as $sys_wbdetails) { $data[] = array( 'waybillno' =&gt; $sys_wbdetails, 'quantity' =&gt; $quantity, 'waybilldate' =&gt; $waybilldate, ); } return $this-&gt;db-&gt;insert_batch('sys_cargodetails', $data); } </code></pre> <h3>View</h3> <pre><code>&lt;?php foreach($waybill_header as $waybill_header) { ?&gt; &lt;?php echo form_open('core/create_cargo_manifest'); ?&gt; &lt;td&gt;&lt;input type="checkbox" name="sys_wbdetails[]" value="&lt;?php echo $waybill_header-&gt;waybillno; ?&gt;"&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $waybill_header-&gt;waybillno; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $waybill_header-&gt;waybilldate; ?&gt;&lt;input type="hidden" value="&lt;?php echo $waybill_header-&gt;waybilldate; ?&gt;" name="waybilldate"&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" size="5" value="&lt;?php echo $waybill_header-&gt;quantity; ?&gt;" name="quantity"&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="submit" value="save"&gt;&lt;/td&gt; &lt;?php } ?&gt; &lt;?php form_close(); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload