-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 に答える