【问题标题】:How to insert data from 3 different input fields together in one column of table in mysql database in codeigniter如何在codeigniter的mysql数据库的一列表中将3个不同输入字段的数据一起插入
【发布时间】:2015-02-10 14:57:30
【问题描述】:

我想在我的数据库表的单列位置插入来自不同输入字段(如国家、州和城市)的数据。我现在有这样的字段。

+----------------+----------------+----------+
|    zipcode     |      city      |   state  |
+----------------+----------------+----------+
|     10954      |     Nanuet     |    NY    |
+----------------+----------------+----------+

但是,我想插入这样的数据。

+---------------------+
|      location       |
+---------------------+
| 10954 - Nanuet, NY  |
+---------------------+

在codeigniter中怎么做?

【问题讨论】:

标签: php mysql codeigniter


【解决方案1】:
$ZIP  = $this->input->post('zipcode');
$CITY = $this->input->post('CITY');
$STATE = $this->input->post('STATE');
$location = $ZIP  .' - '.$CITY .' , '.$STATE ;

你现在可以插入那个位置变量,你的模型查询;

$this->db->insert('tablename', array('location=>$locaiton'))

【讨论】:

  • 欢迎您 :) 如果您对 codeigniter 有任何其他疑问,可以给我发电子邮件 infowiz.tariq@gmail.com
  • 是的,先生,我会的,再次感谢
猜你喜欢
  • 2017-06-16
  • 1970-01-01
  • 2019-08-30
  • 1970-01-01
  • 2013-08-22
  • 2021-01-23
  • 2020-07-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多