foreach无效参数错误

时间:2015-09-11 22:00:51

标签: php

我一直收到foreach的无效参数警告和数字的未定义变量错误,怎么能修复?代码如下所示

<table class="table table-bordered">
  <thead>
    <tr>
      <td colspan='6'><h4><small>Online Players</small></h4></td>
    </tr>
    <td>Player Id</td>
    <td>Nickname</td>
    <td>Score</td>
    <td>Ping</td>
   </thead>

    <?php
    foreach($info as $number) //warning line
    {
      echo "<tr><td>".$number['PlayerID']."</td>";
      echo "<td>".$number['Nickname']."</td>";
      echo "<td>".$number['Score']."</td>";
      echo "<td>".$number['Ping']."</td></tr>";
    }
    if($number == 0)
    {
      echo "<tr><td colspan='6'><small>No players online or the database is too busy..</small></td></tr>";
    }
    ?>
</table>

0 个答案:

没有答案