Php 按钮错误(CodeIgniter和Twitter引导)
在CodeIgniter(PHP)和Twitter引导程序中编写跟随/取消跟随系统。我也有活动的URL路由。按照视图中的按钮代码进行操作Php 按钮错误(CodeIgniter和Twitter引导),php,codeigniter,twitter-bootstrap,Php,Codeigniter,Twitter Bootstrap,在CodeIgniter(PHP)和Twitter引导程序中编写跟随/取消跟随系统。我也有活动的URL路由。按照视图中的按钮代码进行操作 <!-- Follow Button Start --> <?php $is_logged_in = $this->session->userdata('is_logged_in'); ?> <?php if(!(empty($is_logged_in)) && $sID != $vID &&
<!-- Follow Button Start -->
<?php $is_logged_in = $this->session->userdata('is_logged_in'); ?>
<?php if(!(empty($is_logged_in)) && $sID != $vID && !in_array($sID, $following)): ?>
<button class="btn" type="submit" onClick="location.href='<?php echo site_url("follow/$vUsername"); ?>'">Follow <?php echo $vUsername; ?> </button>
<?php elseif (in_array($sID, $following)):?>
<button class="btn" type="submit" onClick="location.href='<?php echo site_url("unfollow/$vUsername"); ?>'">UnFollow <?php echo $vUsername; ?> </button>
<?php else: ?>
<button class="btn disabled" type="submit">Follow <?php echo $vUsername; ?> </button>
<?php endif; ?>
<!-- Follow Button End -->
我不能在这里完全测试它,但这对我来说更有意义:
<?php if((!empty($is_logged_in)) && ($sID != $vID) && (!in_array($sID, $following))): ?>
编辑:
那么,在这种情况下,只有简单的逐步调试才能为您节省:
<?php
$is_logged_in = $this->session->userdata('is_logged_in');
if(!empty($is_logged_in))
{
echo '$is_logged_in is not empty';
}
echo '$sID is: '.$sID.' and it should not be equal to $vID'. $vID;
if($sID != $vID){
echo 'and indeed it is not';
}
else
{
echo 'but it is. Here is the problem';
}
echo 'This is the $following array:';
print_r($following);
if(!in_array($sID, $following))
{
echo '$sID is not in the $following array';
}
else
{
echo '$sID IS in the $following array';
}
?>
已经测试过了,还是没有运气$sID=$this->session->userdata('id')$vID=$this->m_user->fetch_id($data['vUsername'])//fetches User ID$以下是从DB获得的关注者数组。请不要在评论中发布代码,您的初始代码很难阅读,并标有“;”。这确实是你应该能够自己解决的问题,而不是仅仅在这里发布错误。。。。我编辑了我的代码。。。不客气