-2

我有一个无法验证的 HTML 文件,并且不断收到错误Line 65, Column 7: document type does not allow element "table" here;缺少“object”、“applet”、“map”、“iframe”、“button”、“ins”、“del”开始标签之一 <table><tr>

但是我的文档没有第 65 行,代码如下

<!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>
        <link rel="stylesheet" type="text/css" href="style_2.css"></link>
        <title> Gadgets </title>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
    </head>
<body>



    <div class="container">
        <div class="background">
            <div class="innerContainer">
            <?php include("header.php"); ?>
            <div class="content">
            <div class="scroll">
<?php
error_reporting(0);
$con = mysql_connect("xxxxxxxx");
mysql_select_db("xxxx", $con);
$result = mysql_query("SELECT * FROM gadgets");
?>
<p>  
<?php
echo "<table>";  
echo "<tr> 
    <th>Name</th> 
    <th>Description</th> 
    <th>Price</th>
    <th>Manufacturer</th>
    <th>Image</th> 
  </tr>"; 
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" .$row['Name']."</td>";
echo "<td>" .$row['Description'] ."</td>";
echo "<td>" .$row['Price'] ."</td>";
echo "<td><img src='" .$row['ImageURL'] ."' style='width: 200px; height: 150px;' alt='Image' /></td>";
echo "</tr>";
}
echo "</table>"; 
?>
</p>
<?php
mysql_close($con);
?>

            </div>
            </div>
            <?php include("footer.php"); ?>  

        </div>
        </div>
    </div>

</body>
</html> 
4

1 回答 1

4

验证器在 HTML 上运行,而不是 PHP(因此将行号与生成的 HTML 进行比较……还要注意 W3C 验证服务的Show Source选项)。

段落不能包含表格。移动<table>外部<p>

于 2012-05-07T19:29:53.753 回答