按钮错误(CodeIgniter&;Twitter引导程序)


Button Bug (CodeIgniter & Twitter Bootstrap)

CodeIgniter(PHP)中的编码跟随/不允许系统&Twitter引导程序。我也有URLS的活动路线。按照VIEW中的按钮代码操作。

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

即使用户没有跟随,按钮也会显示UnFollow $vUsername

我不能在这里完全测试它,但这对我来说更有意义:

<?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';
}   
?>