问题描述
我在这里得到这个“关注”按钮:
代替此“关注”按钮。
这是我的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;现在还没有发生。
这是我的数据库中的关注表。
这是我的个人资料。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 (将#修改为@)