-1

有人可以帮助我吗,我正在尝试根据我在“权限”表中为每个用户拥有的记录来显示不同的图像。我在用 。

如果表中不存在记录,我想包含不同的文件路径,即

目前,如果用户权限设置为 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'); 
      } 
    } 
} ?>
4

1 回答 1

2

尝试这个:

<?
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';
    }
}
?>
于 2013-01-31T13:20:30.510 回答