“正在关注”按钮未显示

如何解决“正在关注”按钮未显示

我在这里得到这个“关注”按钮

Follow Button


代替此“关注”按钮。

enter image description here


这是我的follow.php。

    <?php
class Follow extends User
{
    
    function __construct($pdo)
    {
        $this->pdo = $pdo;
    }
    public function checkFollow($followerID,$user_id)
    {
        $stmt = $this->pdo->prepare("SELECT * FROM `follow` WHERE `sender` = :user_id AND `reciever` = :followerID");
        $stmt->bindParam(":user_id",$user_id,PDO::PARAM_INT);
        $stmt->bindParam(":followerID",$followerID,PDO::PARAM_INT);
        $stmt->execute();
        return $stmt->fetch(PDO::FETCH_ASSOC);
    }
    
    public function followBtn($profileID,$user_id)
    {
        $data = $this->checkFollow($profileID,$user_id);
        if($this->loggedIn() === true){
            if($profileID != $user_id){
                if($data !== false){
                    //Following Button
                    echo "<button class='f-btn following-btn follow-btn' data-follow='".$profileID."'>Following</button>";
                }else{
                    //follow button
                    echo "<button class='f-btn following-btn follow-btn' data-follow='".$profileID."'><i class='fa fa-user-plus'></i>Follow</button>";
                }
            }else{
                //edit button
                echo "<button class='f-btn' onclick=location.href='profileEdit.php'>Edit Profile</button>";

            }
        }else{
            echo "<button class='f-btn' onclick=location.href='index.php'><i class='fa fa-user-plus'></i>Follow</button>";
        }
    }
}
?>

“关注”按钮位于follow.php中的第28行

echo "<button class='f-btn following-btn follow-btn' data-follow='".$profileID."'>Following</button>";

只想告诉大家,我之前在follow.php中有这一行。 if($data['reciever'] == $profileID) 现在更改为if($data !== false),因为我收到了 ERROR.,同时放置以下行::

if($data['reciever'] == $profileID),但现在在放置以下行之后,错误消失了:

if($data !== false)

我的输出页面没有显示任何错误,它仅显示“关注”按钮而不是“关注”按钮。 我想关注其他人的帐户,并希望在我的关注表中显示followID,sender,reciever,followOn;现在还没有发生。
这是我的数据库中的关注表。

enter image description here


这是我的个人资料。php

<?php
include 'core/init.php';
 if (isset($_GET['username']) === true && empty($_GET['username']) === false) {
  $username = $getFromU->checkInput($_GET['username']);
  $profileId = $getFromU->userIdByUsername($username);
  $profileData = $getFromU->userData($profileId);
  $user_id = @$_SESSION['user_id'];
  $user = $getFromU->userData($user_id);
 
  if (!$profileData) {
    header('Location: '.BASE_URL.'index.php');
  }
}

?>

<!--
   This template created by Meralesson.com
   This template only use for educational purpose
  -->
<!doctype html>
<html>
    <head>
    <title><?php echo $profileData->screenName.' (@'.$profileData->username.')'; ?></title>
    <meta charset="UTF-8" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css"/>
    <link rel="stylesheet" href="<?php echo BASE_URL; ?>assets/css/style-complete.css"/>
    <script src="https://code.jquery.com/jquery-3.1.1.js" integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA=" crossorigin="anonymous"></script>
    </head>
<!--Helvetica Neue-->
<body>
<div class="wrapper">
<!-- header wrapper -->
<div class="header-wrapper">
    <div class="nav-container">
        <div class="nav">
        <div class="nav-left">
            <ul>
                 <li><a href="<?php echo BASE_URL; ?>home.php"><i class="fa fa-home" aria-hidden="true"></i>Home</a></li>
                
                 <?php if($getFromU->loggedIn() === true){ ?>
                
                 <li><a href="<?php echo BASE_URL; ?>i/notifications"><i class="fa fa-bell" aria-hidden="true"></i>Notification</a></li>
                 <li id="messagePopup"><i class="fa fa-envelope" aria-hidden="true"></i>Messages</li>
                
                <?php } ?>
            
            </ul>
        </div><!-- nav left ends-->
        <div class="nav-right">
            <ul>
                <li><input type="text" placeholder="Search" class="search"/><i class="fa fa-search" aria-hidden="true"></i>
                    <div class="search-result">
                    </div>
                </li>
        <?php if($getFromU->loggedIn() === true){ ?>
                <li class="hover"><label class="drop-label" for="drop-wrap1"><img src="<?php echo BASE_URL.$user->profileImage; ?>"/></label>
                <input type="checkbox" id="drop-wrap1">
                <div class="drop-wrap">
                    <div class="drop-inner">
                        <ul>
                            <li><a href="<?php echo BASE_URL.$user->username; ?>"><?php echo $user->username; ?></a></li>
                            <li><a href="<?php echo BASE_URL; ?>settings/account">Settings</a></li>
                            <li><a href="<?php echo BASE_URL; ?>includes/logout.php">Log out</a></li>
                        </ul>
                    </div>
                </div>
                </li>
                <li><label for="pop-up-tweet" class="addTweetBtn">Tweet</label></li>
      <?php }else{
        echo '<li><a href="'.BASE_URL.'index.php">Have an account? Log in!</a></li>';
      } ?>
      </ul>
        </div><!-- nav right ends-->

    </div><!-- nav ends -->
    </div><!-- nav container ends -->
</div><!-- header wrapper end -->
<!--Profile cover-->
<div class="profile-cover-wrap">
<div class="profile-cover-inner">
    <div class="profile-cover-img">
        <!-- PROFILE-COVER -->
        <img src="<?php echo BASE_URL.$profileData->profileCover; ?>"/>
    </div>
</div>
<div class="profile-nav">
 <div class="profile-navigation">
    <ul>
        <li>
        <div class="n-head">
            TWEETS
        </div>
        <div class="n-bottom">
          <?php $getFromT->countTweets($profileId); ?>
        </div>
        </li>
        <li>
            <a href="<?php echo BASE_URL.$profileData->username; ?>/following">
                <div class="n-head">
                    <a href="<?php echo BASE_URL.$profileData->username; ?>/following">FOLLOWING</a>
                </div>
                <div class="n-bottom">
                    <span class="count-following"><?php echo $profileData->following; ?></span>
                </div>
            </a>
        </li>
        <li>
         <a href="<?php echo BASE_URL.$profileData->username; ?>/followers">
                <div class="n-head">
                    FOLLOWERS
                </div>
                <div class="n-bottom">
                    <span class="count-followers"><?php echo $profileData->followers; ?></span>
                </div>
            </a>
        </li>
        <li>
            <a href="#">
                <div class="n-head">
                    LIKES
                </div>
                <div class="n-bottom">
                    <?php $getFromT->countLikes($profileId);?>
                </div>
            </a>
        </li>
    </ul>
    <div class="edit-button">
        <span>
            <?php $getFromF->followBtn($profileId,$user_id);?>
        </span>
    </div>
    </div>
</div>
</div><!--Profile Cover End-->

<!---Inner wrapper-->
<div class="in-wrapper">
 <div class="in-full-wrap">
   <div class="in-left">
     <div class="in-left-wrap">
    <!--PROFILE INFO WRAPPER END-->
    <div class="profile-info-wrap">
     <div class="profile-info-inner">
     <!-- PROFILE-IMAGE -->
        <div class="profile-img">
            <img src="<?php echo BASE_URL.$profileData->profileImage; ?>"/>
        </div>

        <div class="profile-name-wrap">
            <div class="profile-name">
                <a href="<?php echo BASE_URL.$profileData->username; ?>"><?php echo $profileData->screenName; ?></a>
            </div>
            <div class="profile-tname">
                @<span class="username"><?php echo $profileData->username; ?></span>
            </div>
        </div>

        <div class="profile-bio-wrap">
         <div class="profile-bio-inner">
            <?php echo $getFromT->getTweetLinks($profileData->bio); ?>
         </div>
        </div>

<div class="profile-extra-info">
    <div class="profile-extra-inner">
        <ul>
      <?php if(!empty($profileData->country)){ ?>
            <li>
                <div class="profile-ex-location-i">
                    <i class="fa fa-map-marker" aria-hidden="true"></i>
                </div>
                <div class="profile-ex-location">
                    <?php echo $profileData->country; ?>
                </div>
            </li>
    <?php } ?>

    <?php if(!empty($profileData->website)){ ?>
            <li>
                <div class="profile-ex-location-i">
                    <i class="fa fa-link" aria-hidden="true"></i>
                </div>
                <div class="profile-ex-location">
                    <a href="<?php echo $profileData->website; ?>" target="_blank"><?php echo $profileData->website; ?></a>
                </div>
            </li>
    <?php } ?>

            <li>
                <div class="profile-ex-location-i">
                    <!-- <i class="fa fa-calendar-o" aria-hidden="true"></i> -->
                </div>
                <div class="profile-ex-location">
                </div>
            </li>
            <li>
                <div class="profile-ex-location-i">
                    <!-- <i class="fa fa-tint" aria-hidden="true"></i> -->
                </div>
                <div class="profile-ex-location">
                </div>
            </li>
        </ul>
    </div>
</div>

<div class="profile-extra-footer">
    <div class="profile-extra-footer-head">
        <div class="profile-extra-info">
            <ul>
                <li>
                    <div class="profile-ex-location-i">
                        <i class="fa fa-camera" aria-hidden="true"></i>
                    </div>
                    <div class="profile-ex-location">
                        <a href="#">0 Photos and videos </a>
                    </div>
                </li>
            </ul>
        </div>
    </div>
    <div class="profile-extra-footer-body">
        <ul>
             <!-- <li><img src="#"/></li> -->
        </ul>
    </div>
</div>

     </div>
    <!--PROFILE INFO INNER END-->

    </div>
    <!--PROFILE INFO WRAPPER END-->

    </div>
    <!-- in left wrap-->

  </div>
    <!-- in left end-->

<div class="in-center">
    <div class="in-center-wrap">

  <?php

  $tweets = $getFromT->getUserTweets($profileId);

  foreach ($tweets as $tweet) {
    $likes   = $getFromT->likes($user_id,$tweet->tweetID);
    $retweet = $getFromT->checkRetweet($tweet->tweetID,$user_id);
    $user    = $getFromU->userData($tweet->retweetBy);
    
    echo '<div class="all-tweet">
            <div class="t-show-wrap">
             <div class="t-show-inner">
             '.((is_array($retweet) && isset($retweet['retweetID']) ? $retweet['retweetID'] === $tweet->retweetID OR $tweet->retweetID > 0 : '') ? '
              <div class="t-show-banner">
                <div class="t-show-banner-inner">
                  <span><i class="fa fa-retweet" aria-hidden="true"></i></span><span>'.$user->screenName.' Retweeted</span>
                </div>
              </div>'
              : '').'

             '.((!empty($tweet->retweetMsg) && (is_array($retweet) && isset($retweet['tweetID']) && $tweet->tweetID === $retweet['tweetID']) OR $tweet->retweetID > 0) ? '
              <div class="t-show-head">
              <div class="t-show-popup" data-tweet="'.$tweet->tweetID.'">
                <div class="t-show-img">
                  <img src="'.BASE_URL.$user->profileImage.'"/>
                </div>
                <div class="t-s-head-content">
                  <div class="t-h-c-name">
                    <span><a href="'.BASE_URL.$user->username.'">'.$user->screenName.'</a></span>
                    <span>@'.$user->username.'</span>
                    <span>'.$getFromU->timeAgo($tweet->postedOn).'</span>
                  </div>
                  <div class="t-h-c-dis">
                    '.$getFromT->getTweetLinks($tweet->retweetMsg).'
                  </div>
                </div>
              </div>
              <div class="t-s-b-inner">
                <div class="t-s-b-inner-in">
                  <div class="retweet-t-s-b-inner">
                  '.((!empty($tweet->tweetImage)) ? '
                    <div class="retweet-t-s-b-inner-left">
                      <img src="'.BASE_URL.$tweet->tweetImage.'" class="imagePopup" data-tweet="'.$tweet->tweetID.'"/>
                    </div>' : '').'
                    <div>
                      <div class="t-h-c-name">
                        <span><a href="'.BASE_URL.$tweet->username.'">'.$tweet->screenName.'</a></span>
                        <span>@'.$tweet->username.'</span>
                        <span>'.$getFromU->timeAgo($tweet->postedOn).'</span>
                      </div>
                      <div class="retweet-t-s-b-inner-right-text">
                        '.$getFromT->getTweetLinks($tweet->status).'
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              </div>' : '

              <div class="t-show-popup" data-tweet="'.$tweet->tweetID.'">
                <div class="t-show-head">
                  <div class="t-show-img">
                    <img src="'.BASE_URL.$tweet->profileImage.'"/>
                  </div>
                  <div class="t-s-head-content">
                    <div class="t-h-c-name">
                      <span><a href="'.$tweet->username.'">'.$tweet->screenName.'</a></span>
                      <span>@'.$tweet->username.'</span>
                      <span>'.$getFromU->timeAgo($tweet->postedOn).'</span>
                    </div>
                    <div class="t-h-c-dis">
                      '.$getFromT->getTweetLinks($tweet->status).'
                    </div>
                  </div>
                </div>'.
                ((!empty($tweet->tweetImage)) ?
                 '<!--tweet show head end-->
                      <div class="t-show-body">
                        <div class="t-s-b-inner">
                         <div class="t-s-b-inner-in">
                           <img src="'.BASE_URL.$tweet->tweetImage.'" class="imagePopup" data-tweet="'.$tweet->tweetID.'"/>
                         </div>
                        </div>
                      </div>
                      <!--tweet show body end-->
                ' : '').'

              </div>').'
              <div class="t-show-footer">
                <div class="t-s-f-right">
                  <ul>
                  '.(($getFromU->loggedIn() === true) ? '
                    <li><button><i class="fa fa-share" aria-hidden="true"></i></button></li>
                    <li>'.((is_array($retweet) && isset($retweet['retweetID']) ? $retweet['retweetID'] === $tweet->tweetID : '') ? 
                    '<button class="retweeted" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><i class="fa fa-retweet" aria-hidden="true"></i><span class = "retweetsCount">'.$tweet->retweetCount.'</span></button>' : 
                    '<button class="retweet" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><i class="fa fa-retweet" aria-hidden="true"></i><span class = "retweetsCount">'.(($tweet->retweetCount > 0) ? $tweet->retweetCount : '').'</span></button>').'
                    </li>
                    <li>'.((isset($likes['likeOn']) ? $likes['likeOn'] === $tweet->tweetID : '') ? 
                                    '<button class="unlike-btn" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><i class="fa fa-heart" aria-hidden="true"></i><span class="likesCounter">'.(($tweet->likesCount > 0) ? $tweet->likesCount : '' ).'</span></button>' : 
                                    '<button class="like-btn" data-tweet="'.$tweet->tweetID.'" data-user="'.$tweet->tweetBy.'"><i class="fa fa-heart-o" aria-hidden="true"></i><span class="likesCounter">'.(($tweet->likesCount > 0) ? $tweet->likesCount : '' ).'</span></button>').'
                    </li>    
                    '.(($tweet->tweetBy === $user_id) ? '
                      <li>
                          <a href="#" class="more"><i class="fa fa-ellipsis-h" aria-hidden="true"></i></a>
                          <ul>
                            <li><label class="deleteTweet" data-tweet="'.$tweet->tweetID.'">Delete Tweet</label></li>
                          </ul>
                      </li>' : '').'

                   ' : '<li><button><i class="fa fa-share" aria-hidden="true"></i></button></li>
                        <li><button><i class="fa fa-retweet" aria-hidden="true"></i></button></li>
                        <li><button><i class="fa fa-heart" aria-hidden="true"></i></button></li>
                    ').'

                  </ul>
                </div>
              </div>
            </div>
            </div>
            </div>';
  }
  ?>
    </div><!-- in left wrap-->
  <div class="popupTweet"></div>
  <script type="text/javascript" src="<?php echo BASE_URL; ?>assets/js/like.js"></script>
  <script type="text/javascript" src="<?php echo BASE_URL; ?>assets/js/retweet.js"></script>
  <script type="text/javascript" src="<?php echo BASE_URL; ?>assets/js/popuptweets.js"></script>
  <script type="text/javascript" src="<?php echo BASE_URL; ?>assets/js/delete.js"></script>
  <script type="text/javascript" src="<?php echo BASE_URL; ?>assets/js/comment.js"></script>
  <script type="text/javascript" src="<?php echo BASE_URL; ?>assets/js/popupForm.js"></script>
  <script type="text/javascript" src="<?php echo BASE_URL; ?>assets/js/fetch.js"></script>
  <script type="text/javascript" src="<?php echo BASE_URL; ?>assets/js/search.js"></script>
  <script type="text/javascript" src="<?php echo BASE_URL; ?>assets/js/hashtag.js"></script>
 
</div>
<!-- in center end -->

<div class="in-right">
    <div class="in-right-wrap">

        <!--==WHO TO FOLLOW==-->
             <!-- HERE -->
        <!--==WHO TO FOLLOW==-->

        <!--==TRENDS==-->
            <!-- HERE -->
        <!--==TRENDS==-->

    </div><!-- in right wrap-->
</div>
 <!-- in right end -->

        </div>
        <!--in full wrap end-->
    </div>
    <!-- in wrappper ends-->
 </div>
 <!-- ends wrapper -->
</body>
</html>

我的profile.php完全正常工作,我只在第131行添加了一行。

<?php $getFromF->followBtn($profileId,$user_id);?>

所以,我的问题是我希望显示“关注”按钮而不是“关注”按钮,并且当我将其更改为
if ($data !== false)if ($data !== true)时,我得到了“关注”按钮,但在我的关注表中没有看到任何行(followID,sender,reciever,followOn没有值。)

这个社区最近为我提供了很多帮助,我真的很感谢你们每个人!我非常感谢您的任何建议,评论或任何帮助!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res