![](/img/trans.png)
[英]PHP (MySQL) Script doesn't read anything else once I add 'echo' and take something from table
[英]If no results exist in mysql table echo something else?
有人可以幫我嗎,我試圖根據我在“權限”表中為每個用戶提供的記錄來顯示不同的圖像。 我在用 。
如果記錄不存在於表中,我想包含其他文件路徑,即
目前,如果用戶權限設置為1或0,它會顯示結果,但我想這樣做,以便在表中未找到結果時顯示默認值。
碼:
<?php if (logged_in()) {
$account_perms = account_perms();
while ($perms = mysql_fetch_array($account_perms)) {
if ($perms['privellages'] == '1') {
if ( mysql_num_rows( $perms ) > 0 )
include('includes/mod_profile/mod_photos/private.php');
}
}
$account_perms = account_perms();
while ($perms = mysql_fetch_array($account_perms)) {
if ($perms['privellages'] == '0') {
include('includes/mod_profile/mod_photos/private2.php');
}
}
$account_perms = account_perms();
while ($perms = mysql_fetch_array($account_perms)) {
if($perms->num_rows > 0) {
include('includes/mod_profile/mod_photos/private2.php');
}
}
} ?>
嘗試這個:
<?
if (logged_in()) {
$account_perms = account_perms();
if (mysql_num_rows($account_perms)) {
while ($perms = mysql_fetch_array($account_perms)) {
if ($perms['privellages'] == '1') {
if (mysql_num_rows($perms) > 0)
include ('includes/mod_profile/mod_photos/private.php');
}
}
} else {
echo 'No records';
}
$account_perms = account_perms();
if (mysql_num_rows($account_perms)) {
while ($perms = mysql_fetch_array($account_perms)) {
if ($perms['privellages'] == '0') {
include ('includes/mod_profile/mod_photos/private2.php');
}
}
} else {
echo 'No records';
}
$account_perms = account_perms();
if (mysql_num_rows($account_perms)) {
while ($perms = mysql_fetch_array($account_perms)) {
if ($perms -> num_rows > 0) {
include ('includes/mod_profile/mod_photos/private2.php');
}
}
} else {
echo 'No records';
}
}
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.