利用COUNT() 函数返回匹配指定条件的行数。
SELECT COUNT(Customer) AS CustomerNilsen FROM Orders WHERE Customer='Carter'
$res = mysqli_query($conn, "select count(code) as num from tb_shopping where code = '{$code}' and username = '{$username}';");
$rew = mysqli_fetch_assoc($res);
if ($rew['num'] == 0) {
echo "内容1"
}else {
echo "内容2"
}