我在数组 fromat 中发布值 og 动态创建的输入字段
<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> <p> </p></p>
<p> <p> </p></p>
<div id="div">
</div>
<p> </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> </p><p> </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> <div class='_25'><input type='textbox' id='textbox' name='stop["+counter+"]' placeholder='Stop Name'></input></div> <div class='_25'><input type='textbox' id='textbox' name='timing["+counter+"]' placeholder='Timing'></input></div> <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>
现在我正在使用这个 codeigniter 脚本将它发布到数据库中
// form 1st text box input
foreach ($_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 input
foreach ($_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 input
foreach ($_POST['ampm'] as $ampmIndex => $ampmValue) {
$sql="INSERT INTO t_routes_list(am_pm) VALUES('".$this->db->escape_str($ampmValue)."')";
$this->db->query($sql);
}
现在 1 只想按 1 发布数据
如何同时发布所有数据?
程序员请帮我编写 php 脚本