php判断为空就插入,判断不为空就更新

if ($_GET['tplname']!==null) {
if ($userinfo[0] == ''){$exec="INSERT INTO cblej_company_pc_templates (REL_ID, NAME, SET_TIME) VALUES ('".$_SESSION['COMPANY_ID']."', '".$_GET['tplname']."', '$adddate')";
}elseif($userinfo[0] !== ''){ $exec="update cblej_company_pc_templates set NAME='".$_GET['tplname']."' where REL_ID = '".$_SESSION['COMPANY_ID']."'"; }
$result = $db->query($exec);
echo "<script>alert('操作成功');location.href='".$_SERVER["HTTP_REFERER"]."';</script>";
}

posted @ 2018-11-15 22:42  阿波罗任先生  阅读(1212)  评论(0编辑  收藏  举报