doucao1888 2014-02-08 17:14
浏览 32
已采纳

表格打印仅在php标签之外的<table>标签时

From everywhere I look and research it seems possible to also put the tags within your php code, but for some reason only when my tag is outside of php it works. I can't seem to figure out the issue with it. The reason I am trying to print inside is because I am trying to create a nested for loop. Currently I commented out the table tags outside of the php and have them printed in the php code. This currently does not work. Here is my code and thank you again.

<?php print( '<?xml version = "1.0" encoding = "utf-8"?>') ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>User selection page</title>
    </head>

    <!-- <table border="1px"> -->
    <!-- <tbody> -->
    <?php
        /*
        Version 1.1: Instead of printing the teams in different cells we are going to print the 
        games in one row and we select the game itself to see if an upset will occur.
        */


        require_once('Conference.php');         
        $loadGameClass = new Conference();
        $loadGameClass->loadTeams(array("(1)Gonzaga vs (16)Southern U", "(8)Pittsburgh vs (9)Wichita St", "(5)Wisconsin vs (12)Ole Miss", "(4)Kansas st vs (13)Boise St", "(6)Arizona vs (11)Belmont", "(3)New Mexico vs (14) Harvard", "(7)Notre Dame vs (10)Iowa St", "(2)Ohio St vs (15) Iona"));
        $teams = $loadGameClass->getTeams();

        echo "<table border="1">";

        for ($i = 0; $i < 8; $i++) 
        {
        $highSeed = $teams[$i];
        //$lowSeed = $teams[((2*8)-1)-$i];
        echo "<tr><td>$highSeed</td>"; //<td>$lowSeed</td></tr>
        }

        echo "</table>";
    ?>
    <!-- </tbody> -->
    <!-- </table> -->

    <body>
    </body>
</html>
  • 写回答

1条回答 默认 最新

  • douyun3799 2014-02-08 17:16
    关注

    First issue is

    echo "<table border="1">";
    

    it should be

    echo '<table border="1">';
    

    then

    echo "<tr><td>$highSeed</td>";
    

    better way is

    echo '<tr><td>'.$highSeed.'</td></tr>';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 虚心请教几个问题,小生先有礼了
  • ¥30 截图中的mathematics程序转换成matlab