我正在寻找解决问题的方法。
如果我搜索的电子邮件都在我的数据库中,它应该回显“折扣”,否则它应该回应“没有折扣”
//Database is connected
$amail= "SELECT `mail` FROM `wunderte_wp793`.`Newsmail` WHERE `mail` = (\'" . $_GET['mail'] . "\');";
$resultamail = $mysqli->query($amail); // query
$email= "SELECT `email` FROM `wunderte_wp793`.`message` WHERE `email` = (\'" . $_GET['mail'] . "\');";
$resultemail = $mysqli->query($email); // query
while($resultamail == $resultemail){
echo "Discount";
}
else {
echo "NULL discount";
}
答案 0 :(得分:1)
使用MySQL if
SELECT if(mail=email,'Discount','NULL discount') result FROM
`wunderte_wp793`
WHERE `mail` = 'xyz' or email='xyz'
MySQL IF
函数是MySQL控制流函数之一,它根据条件返回值。