[英]How to [erform condition when null is retrived from the database using php?
I am retrieving the details from the database if the condition is satisfied. 如果满足条件,我将从数据库中检索详细信息。 But when the condition is not satisfied, empty result is retrived.
但是当不满足条件时,将检索空结果。 So how to have a condition if status is empty
那么如果状态为空怎么办
My code 我的密码
php 的PHP
$sq=mysqli_query($link,$query);
$ro=mysqli_fetch_array($sq);
$status=$ro['status'];
if($status==1){
header("location: paymentPage.php");
}
else if($status==0){
header("location:login.php");
}
else if($status == '\0')
{
header("location:SignUp.php");
}
But i am not able to redirect to signup page if the status is empty. 但是,如果状态为空,则无法重定向到注册页面。 Can anyone help me solve this problem.Is status=='\\0' is correct to go for signup page.
谁能帮我解决这个问题。status =='\\ 0'是否正确,可以进入注册页面。
Thank You in advance. 先感谢您。
If your column status has integer type in DB then it can't have value '\\0' because '\\0' is a string. 如果您的列状态在DB中为整数类型,则其值不能为'\\ 0',因为'\\ 0'是字符串。 Maybe you should use
is_null
function? 也许您应该使用
is_null
函数? For example: 例如:
else if(is_null($status))
{
header("location:SignUp.php");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.