php - how to post data from array to database -


hello coders. have problem inserting data database, can please me controller function? here php form:

<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>         </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> 

adn controller function :

public function output()     {     $common['common']=$this->common;     $this->load->helper('form');     $this->load->database();       foreach ($_post['stop'] $stopindex => $stopvalue) {      if($stopvalue!=null)     {      echo $stopindex;     echo $stopvalue;          }     }     foreach ($_post['timing'] $timingindex => $timingvalue)     {     if($timingvalue!=null)     {     echo $stopvalue['data'];     }   } foreach ($_post['ampm'] $ampmindex => $ampmvalue) {    if($timingvalue!=null)     {   echo $ampmvalue;   } }      $this->output->enable_profiler(true);     }    

and these database fields:

route_number   stop_name   am_pm   timing 

please give me way insert query post these input fields database.

do have model made? in codeigniter supposed direct db activities model. need know models explained here: http://ellislab.com/codeigniter/user-guide/general/models.html

once there insert explained here: http://ellislab.com/codeigniter/user-guide/database/examples.html eventhough use active record class way (http://ellislab.com/codeigniter/user-guide/database/active_record.html), it's simpler , abstraction helpful.


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" -