query("SELECT * FROM kefu WHERE kefu='" . $kefu . "'"); if ($result->num_rows == 0) { // 数据库中不存在该记录,执行插入操作 $data = $con->query("INSERT INTO kefu (kefu, qrcode, kfwx, ontime, appid, `key`, `link_color`) VALUES ('" . $kefu . "', '" . $qrcode . "', '" . $kfwx . "', '" . $ontime . "', '" . $appid . "', '" . $key . "', '" . $link_color . "')"); if ($data > 0) { echo " "; } else { echo (""); } } else { // 数据库中存在该记录,执行更新操作 $data = $con->query("UPDATE kefu SET qrcode ='" . $qrcode . "',kfwx='" . $kfwx . "',ontime='" . $ontime . "',appid='" . $appid . "', `key`='" . $key . "', `link_color`='" . $link_color . "' WHERE kefu='" . $kefu . "'"); if ($data > 0) { echo " "; } else { echo (""); } } } $con->close(); ?>