通知消息

时间:2017-01-02 07:48:43

标签: php html

这是我的代码。数字为什么没有显示?

计数不起作用

<ul class="nav navbar-top-links navbar-right">
    <li class="dropdown">
        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
            <i class="fa fa-envelope fa-fw"></i> <i class="fa fa-caret-down"></i>
        </a>
        <ul class="dropdown-menu dropdown-messages">
            <!-- /try notification -->
            <?php
            $connect = mysqli_connect("localhost", "root", "", "pdn"); 
            $count = "SELECT status, count(*) as number FROM urusan_khas WHERE status='dalamproses'";
            $result = mysqli_query($connect, $count); 
            echo "$count";
            ?>
            <li class="header">You have <?php echo $count ?> messages</li>
            <!-- /try notification -->
        </ul>
    </li>
</ul>

任何解决方案?

1 个答案:

答案 0 :(得分:1)

在你的代码中,你需要回复$ result而不是$ count,如下所示,

<?php
$connect = mysqli_connect("localhost", "root", "", "pdn"); 
$count = "SELECT status, count(*) as number FROM urusan_khas WHERE status='dalamproses'";
$result = mysqli_query($connect, $count); 
$result = mysqli_fetch_assoc($result); 
echo $result['number'];
?>
<li class="header">You have <?php echo $result['number']; ?> messages</li>