dongmei6426 2016-05-13 06:22
浏览 25

为什么我的桌子没有显示?

I'm having some trouble with my website. It uses HTML with embedded PHP. I have a schedule page that pulls information from a CSV file and displays it as a table on the site, to make it easier to update schedules, but it's not working for some reason. Here's the code (I cut out the unimportant stuff).

<html>
<head>
</head>
<body>
<table>
<?php
     $f = fopen("schedule.csv", "r");
     while (($line = fgetcsv($f)) !== false)
     {
          $row = $line[0]; // We need to get the actual row (it is the first element in a 1-element array)
          $cells = explode(";",$row);
          echo "<tr>";
          foreach ($cells as $cell)
          {
               echo "<td>" . htmlspecialchars($cell) . "</td>";
          }
          echo "</tr>
";
     }
     fclose($f);
?>
</table>
</body>
</html>

However, when I try opening the webpage, all I get is:

foreach ($cells as $cell) { echo ""; } echo "
"; } fclose($f); ?>

" . htmlspecialchars($cell) . "

I can't tell if I'm missing a punctuation or what. I basically copied it from another site that another programmer recommended to someone else, so I don't know what's wrong.

  • 写回答

2条回答 默认 最新

  • duanche2007 2016-05-13 06:37
    关注

    Use single quotes instead

    <html>
    <head>
    </head>
    <body>
    <table>
    <?php
         $f = fopen('schedule.csv', 'r');
         while (($line = fgetcsv($f)) !== false)
         {
              $row = $line[0]; // We need to get the actual row (it is the first element in a 1-element array)
              $cells = explode(';',$row);
              echo '<tr>';
              foreach ($cells as $cell)
              {
                   echo '<td>' . htmlspecialchars($cell) . '</td>';
              }
              echo '</tr><br/>';
         }
         fclose($f);
    ?>
    </table>
    </body>
    </html>
    
    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)