脚本宝典收集整理的这篇文章主要介绍了php – 通过表单将数据从一个表插入另一个表,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我如何做到的,可能会有所帮助:
$query = $this->db->get('Table1')->result(); // get First table foreach($query as $result) { //Your Post Values From form data IN ARRAY : POST_DATA $post_data = array_from_post('filed1,filed2....'); $data = array_merge($result,$post_data); $this->db->insert('Table2',$data); // insert each row to another table }
在这里我已经在我的基础模型中定义了array_from_post,您可以像这样使用它:
public function array_from_post($fields){ $data = array(); foreach ($fields as $field) { $data[$field] = $this->input->post($field); } return $data; }
以上是脚本宝典为你收集整理的php – 通过表单将数据从一个表插入另一个表全部内容,希望文章能够帮你解决php – 通过表单将数据从一个表插入另一个表所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。