【发布时间】:2020-11-19 15:05:27
【问题描述】:
有两个数据库。我正在尝试查看第一个数据库中的电子邮件是否也存在于第二个数据库中。这是我尝试过的代码:
// Getting info from the first "subscribers" database.
$sql = "SELECT name, email, status
FROM subscribers
WHERE status='active'";
$result = mysqli_query($link,$sql);
while($row = mysqli_fetch_assoc($result)) {
// To check if all emails in "subscribers" database are also present in "phpbb_users" database.
// If they are present then user type=0 otherwise user type=1.
$subscriber_email = $row['email'];
$forum_sql = mysqli_query($forum_link, "SELECT user_type
FROM phpbb_users
WHERE user_email='$subscriber_email'");
while($forum_row = mysqli_fetch_assoc($forum_sql)){
$ut = $forum_row['user_type'];
if($ut=="0"){
$type="0";
} else {
$type="1";
}
echo $type;
}
// To diplay the data from "subscribers" database.
echo $row["name"];
echo $row['email'];
}
输出是:
onera 和 julian 的类型为空,因为 phpbb_users 数据库中不存在电子邮件。我怎样才能避免这个空白并将其设为 1 或其他任何内容。 var_dump() 什么也不显示。
【问题讨论】:
-
输出列表的代码会很有帮助。正确缩进代码总是好的——它可以更容易地消化正在发生的事情