如何执行两个if语句

时间:2016-05-13 14:04:04

标签: php

我有两种用户类型。有些人在网站上注册,有些人在Facebook上感叹。

如果用户注册Facebook,我将加载个人资料图片。 问题是我只想加载一张图片,如果它们来自facebook,而我的代码到目前为止并没有在我的elseif语句之后加载内容

 @Override
public void onBackPressed() {

    int count = getFragmentManager().getBackStackEntryCount();
    //pop all fragments till it remains the first fragment then move to background
    if (count == 1) {
        super.onBackPressed();
        //additional code
    } else {
        getFragmentManager().popBackStack();
    }

}

如何在我的elseif语句中加载配置文件picuture而不结束我的第一个if语句?

2 个答案:

答案 0 :(得分:1)

只需添加另一个if - endif对,就像这样:

<body>
<!--  After user login  -->
  <?php if ($_SESSION['Femail']): ?> 

    <div class="container">
      <div class="hero-unit">
        <h1>Hello <?php echo $_SESSION['FIRST_NAME']; ?></h1>
      </div>

      <div class="span4">
        <?php if ($_SESSION['FBID']): ?> 
          <img src="https://graph.facebook.com/<?php echo $_SESSION['FBID']; ?>/picture">
        <?php endif; ?>

        <div>
          <div id="userProfile">
        </div>
        <a href="logout.php">Log out</a>
      </div>

    </div>

  <?php else: ?> 
    <h3>Not logged in</h3>
  <?php endif; ?>
</body>

您可以根据需要嵌套控制语句。

答案 1 :(得分:0)

  

“所有用户 都有会话'Femail'”

删除$sql = "SET @uid := (SELECT ID FROM channels WHERE Used = 0 ORDER BY RAND() LIMIT 1);"; $sql = "UPDATE channels SET Used = 1 WHERE ID = @uid;"; $sql = "SELECT * FROM channels WHERE ID IN = @uid;"; $result = mysqli_multi_query($conn, $sql) or die( mysqli_error($sql) ); if (mysqli_num_rows($result) > 0) { $text = ''; while($row = mysqli_fetch_assoc($result)) { $Channel_Location = $row['Channel_Location']; $text = $text . $Channel_Location; } } 并将其替换为常规elseif,否则if块将永远不会执行,因为“所有用户拥有会话elseif