大家好。我有一段我不理解的PHP代码,需要尽可能详细的说明。我已粘贴以下代码:
$customer_id = $_POST['customer_id'];
if (isset($_POST['group'])){
$group_id = $_POST['group'];
$this->db->where('customer_id',$customer_id);
$query = $this->db->get('customer');
$row = $query->row();
$customer_group_id = $row->group_id;
if ($customer_group_id != $group_id){
$this->db->where('customer_id',$customer_id);
$this->db->update('customer',array("group_id" => $group_id));
}
}
我是php和web的新手。请尽可能帮助我。非常感谢大家的时间和帮助。我的问题可能不太好,但请原谅我。
答案 0 :(得分:0)
它正在查看一些POST输入(可能来自HTML表单提交?):
$_POST['customer_id']
$_POST['group']
如果提交中有group
参数,请将结果值保存在$group_id
...
if (isset($_POST['group'])){
$group_id = $_POST['group'];
...
...使用发布的$customer_id
:
$customer_id = $_POST['customer_id'];
...
$this->db->where('customer_id',$customer_id);
$query = $this->db->get('customer');
$row = $query->row();
检查group_id数据库字段是否与发布的字段不同:
$customer_group_id = $row->group_id;
if ($customer_group_id != $group_id){
...
如果不同,请更新客户的数据库记录:
$this->db->where('customer_id',$customer_id);
$this->db->update('customer',array("group_id" => $group_id));