Codeigniter:IF(条件){insert table1} ELSE {插入另一个表}

时间:2017-09-18 07:09:20

标签: php mysql codeigniter if-statement

有可能吗?

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

我想在codeigniter中这样做。如果selct框选择的值是趋势,那么我想在trendingTable中插入该博客,否则如果该值是其他东西,那么我想将其插入另一个表。

1 个答案:

答案 0 :(得分:0)

if($this->input->post('selectname') == 'Trending_blog'){
$this->db->insert('tbl1',$data);
}
else{
$this->db->insert('tbl2',$data);
}

//You can try this code
相关问题