php中的while循环出错了

时间:2016-05-22 13:12:56

标签: php mysql

任何人都可以帮我看看吗?我想取一个数字,但我得到了这个错误

  

解析错误:第12行的E:\ Software \ Xampp \ htdocs \ pme \ main \ user_online.php中的语法错误,意外';',期待']'

这是我的代码

<?php 

    include '../config.php';

    $sql= mysqli_query($connection,' select * from session');
    $row = mysqli_num_rows($sql);

    while($extract = mysqli_fetch_array($sql)){
        echo
        "<div class='left-total-user-online' id='left-total-user-online'>

            total user online : " .$extract[$row = mysqli_num_rows($sql);]. "</div>";

    }

?>

1 个答案:

答案 0 :(得分:2)

你的生活比必要的复杂得多。所有你需要编码的是

<?php 

    include '../config.php';

    $sql= mysqli_query($connection,' select * from session');
    $row = mysqli_num_rows($sql);

    echo "<div class='left-total-user-online' id='left-total-user-online'>
            total user online : $row</div>";
    }
?>