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

sweemsteree

New Member
i am posting values og dynamically created input fields in array fromat\[code\]<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="http://stackoverflow.com/questions/15888924/Add" onclick="generateRow() "/></a></p></div><input type='button' value='http://stackoverflow.com/questions/15888924/Remove Button' id='removeButton'><p>&nbsp;</p><p>&nbsp;</p></div> <input type="submit" class="button blue" id="button" value="http://stackoverflow.com/questions/15888924/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>\[/code\]now i am using this codeigniter script to post it in data base\[code\]// form 1st text box inputforeach ($_POST['stop'] as $stopIndex => $stopValue) { $sql="INSERT INTO t_routes_list(stop_name) VALUES('".$this->db->escape_str($stopValue)."')"; $this->db->query($sql);} // form 2nd text box inputforeach ($_POST['timing'] as $timingIndex => $timingValue) { $sql="INSERT INTO t_routes_list(timing) VALUES('".$this->db->escape_str($timingValue)."')"; $this->db->query($sql);}// form 3rd select box inputforeach ($_POST['ampm'] as $ampmIndex => $ampmValue) { $sql="INSERT INTO t_routes_list(am_pm) VALUES('".$this->db->escape_str($ampmValue)."')"; $this->db->query($sql);}\[/code\]now 1 want to post data 1 by 1 only which is entered.. but when i am posting it all the fields getting posted by null valuehow to post all data simultaneously?coders pleas help me with the php script
 
Top