Io ho questa pagina:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<HTML lang="it">
<HEAD>
<meta name="description" content="">
<meta name="author" lang="it" content="Rispo Veronica">
<meta name="keywords" lang="it" content="">
<meta http-equiv="Content-type" content="text/html; charset=ISO-8859-1">
<TITLE> Menu' </TITLE>
</HEAD>
<BODY>
<DIV>
<?php
$nomeHost = "localhost";
$nomeUtente = "root";
$password = "";
$nomeDb = "mydb";
// connessione con il MySQL server
$connessione = mysql_connect($nomeHost, $nomeUtente, $password)
or die("Impossibile connettersi all'host $nomeHost");
// seleziona il database
mysql_select_db($nomeDb)
or die( "Impossibile selezionare il database $nomeDb ");
// seleziona i menù pizze
$query = "SELECT * FROM pizze";
$query1 = "SELECT * FROM ingredienti";
$risultato = mysql_query($query) or die("Query fallita".mysql_error());
$risultato1 = mysql_query($query1) or die("Query fallita".mysql_error());
$numero = mysql_numrows($risultato);
$numeroi = mysql_numrows($risultato1);
$listapizze=array($numero);
$elemento=array();
for($j=0;$j<$numero;$j++) {
$riga = mysql_fetch_array($risultato);
$stringa="";
for($i=3;$i<=12;$i++){
for($k=0;$k<$numeroi;$k++){
$rigaingr = mysql_fetch_array($risultato1);
if($riga[$i]==$rigaingr['Cod_Ingrediente']){
$stringa .= $rigaingr['Descrizione'];
$stringa .= " ";
}
}
$risultato1 = mysql_query($query1) or die("Query fallita".mysql_error());
}
$elemento[0]=$riga['Descrizione'];
$elemento[1]=$stringa;
$elemento[2]=$riga['Pomodoro'];
$elemento[3]=$riga['Prezzo'];
$listapizze[]=$elemento;
}
echo "<table>";
foreach($listapizze as $elemento) { //ciclo gli elementi
echo "<tr>";
for($i=0;$i<4;$i++) { //ciclo le proprietà di ciascun elemento
echo "<td>$elemento[$i]</td>";
}
echo "</tr>";
}
echo "</table>";
// chiude la connessione al database
mysql_close($connessione);
?>
</DIV>
</BODY>
</HTML>
Perchè validandola per lo HTML 4.01 Strict dtd mi da questi errori nella parte che riguarda la tabella? Come posso risolverli?
Errori:
Validation Output: 4 Errors
Error Line 60, Column 14: document type does not allow element "TR" here
echo "<tr>";
The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).
One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).
Error Line 60, Column 15: character data is not allowed here
echo "<tr>";
You have used character data somewhere it is not permitted to appear. Mistakes that can cause this error include:
putting text directly in the body of the document without wrapping it in a container element (such as a
aragraph</p>), or
forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes), or
using XHTML-style self-closing tags (such as <meta ... />) in HTML 4.01 or earlier. To fix, remove the extra slash ('/') character. For more information about the reasons for this, see Empty elements in SGML, HTML, XML, and XHTML.
Error Line 64, Column 15: end tag for element "TR" which is not open
echo "</tr>";
The Validator found an end tag for the above element, but that element is not currently open. This is often caused by a leftover end tag from an element that was removed during editing, or by an implicitly closed element (if you have an error related to an element being used where it is not allowed, this is almost certainly the case). In the latter case this error will disappear as soon as you fix the original problem.
Error Line 66, Column 17: end tag for element "TABLE" which is not open
echo "</table>";
The Validator found an end tag for the above element, but that element is not currently open. This is often caused by a leftover end tag from an element that was removed during editing, or by an implicitly closed element (if you have an error related to an element being used where it is not allowed, this is almost certainly the case). In the latter case this error will disappear as soon as you fix the original problem.