【问题标题】:Codeigniter: IF(condition){ insert table1 } ELSE { insert into another table}Codeigniter: IF(condition){ insert table1 } ELSE { insert into another table}
【发布时间】:2017-09-18 07:09:20
【问题描述】:

有可能吗?

if(selectboxValue == Trending_blog)
{
    insert into trendingTable;
} else {
    insert into anotherTable;
}

我想在 codeigniter 中进行。如果选择框选择的值是趋势,那么我想将该博客插入到趋势表中,否则如果该值是其他值,那么我想将它插入到另一个表中。

【问题讨论】:

  • 是的,这是可能的。您到底遇到了什么问题?
  • 我不知道如何在codeigniter中使用控制器和模型
  • 是的,如果你写了代码而不是在这里问,你会自己得到答案

标签: php mysql codeigniter if-statement


【解决方案1】:
if($this->input->post('selectname') == 'Trending_blog'){
$this->db->insert('tbl1',$data);
}
else{
$this->db->insert('tbl2',$data);
}

//You can try this code

【讨论】:

    猜你喜欢
    • 2015-04-12
    • 2010-10-26
    • 2011-11-21
    • 2023-02-09
    • 1970-01-01
    • 2011-12-04
    • 2014-05-12
    • 2023-03-18
    • 1970-01-01
    相关资源
    最近更新 更多