php - how to post value of 3 input field posting in arry into database -


i posting values og dynamically created input fields in array fromat

<form method='post' action='<?php echo site_url('a3_bus_system/output')?>'> <div class="_25"> <strong>route name/number</strong>      <br/> <input type="text" name=""></input> </div> <p>&nbsp;<p>&nbsp;</p></p> <p>&nbsp;<p>&nbsp;</p></p> <div id="div"> </div> <p>&nbsp;</p><div class="_25"> <p><input type="button" name="button" class="button red" id="button" value="add"  onclick="generaterow() "/></a></p> </div> <input type='button' value='remove button' id='removebutton'> <p>&nbsp;</p><p>&nbsp;</p></div>  <input type="submit"  class="button blue" id="button" value="register" /> /form>   </div> </div> <div class="clear height-fix"></div> </div></div> <!--! end of #main-content --> </div> <!--! end of #main --> <script> var counter=1;     function generaterow() {     var count="<font color='red'>"+counter+"</font>";    var temp ="  <p>&nbsp;&nbsp;&nbsp;&nbsp;<div class='_25'><input type='textbox' id='textbox' name='stop["+counter+"]' placeholder='stop name'></input></div>&nbsp;&nbsp;&nbsp;<div class='_25'><input type='textbox' id='textbox' name='timing["+counter+"]' placeholder='timing'></input></div>&nbsp;<div class='_25'><select id='ampm' name='ampm["+counter+"]'><option>a.m</option><option>p.m</option></select>  </div>";  var newdiv = document.createelement('div'); newdiv.innerhtml = temp + count;  var yourdiv = document.getelementbyid('div');  yourdiv.appendchild(newdiv); counter++;     }  </script> 

now using codeigniter script post in data base

// form 1st text box input foreach ($_post['stop'] $stopindex => $stopvalue) {          $sql="insert  t_routes_list(stop_name) values('".$this->db->escape_str($stopvalue)."')";      $this->db->query($sql);  }     // form 2nd text box input    foreach ($_post['timing'] $timingindex => $timingvalue)     {      $sql="insert  t_routes_list(timing) values('".$this->db->escape_str($timingvalue)."')";      $this->db->query($sql); } // form 3rd select box input foreach ($_post['ampm'] $ampmindex => $ampmvalue) {    $sql="insert  t_routes_list(am_pm) values('".$this->db->escape_str($ampmvalue)."')";      $this->db->query($sql); } 

now 1 want post data 1 1 entered.. when posting fields getting posted null value

how post data simultaneously?

coders pleas me php script

mate, in codeigniter exists active records

create models/model_insert.php ad hoc , put inside insert function:

class model_insert extends ci_model{  function insert($data){   $this->db->insert('mytable',$data); }   } 

now have in controller insert data in "mytable":

$this->load->model('model_insert'); $data = array('id'=>$id,'email'=>$email); $this->model_insert->insert($data); 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -