douqi3195 2016-05-13 14:04
浏览 147
已采纳

如何执行两个if语句

I have two user types. Some who signup on the site and some who sigh up with facebook.

If the user signup with facebook i'm loading the profile picture. The problem is that i only want to load a picture if they come from facebook, and my code so far doesn't load the content after my elseif statement

<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 elseif ($_SESSION['FBID']): ?> 
        <img src="https://graph.facebook.com/<?php echo $_SESSION['FBID']; ?>/picture">
        <div>
          <div id="userProfile">

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

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

How do i load the profile picuture in my elseif statement without ending my first if statement?

  • 写回答

2条回答 默认 最新

  • douyoufan7881 2016-05-13 14:10
    关注

    Just add another if-endif pair, like this:

    <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>
    

    You can nest control statements as deeply as you like.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?