我想要像这样的表头:NUME,DECEDATI等我试过echo 也是,它不起作用。请帮我!
PHP代码:
<?php
print "<table";
print "<tr>";
print "<th>NUME </th>";
print "<th> DECEDATI </th>";
print "<th> RANITI </th>";
print "<th> DISPARUTI </th>";
print "<th> CLADIRI DISTRUSE </th>";
print "<th> DURATA </th>";
print "<th> MAGNITUDINE </th>";
print "<th> ADANCIME </th>";
print "<th> PAGUBE MATERIALE </th>";
print "<th> NUMAR REPLICI </th>";
print "</tr>";
print "</table>";
$conn = oci_connect('student', 'STUDENT', 'localhost/XE');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
// Prepare the statement
$stid = oci_parse($conn, "SELECT * FROM nepal ORDER BY ".$_GET['categorie']." ".$_GET['ordine']);
if (!$stid) {
$e = oci_error($conn);
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
// Perform the logic of the query
$r = oci_execute($stid);
if (!$r) {
$e = oci_error($stid);
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
// Fetch the results of the query
print "<table border='1'>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
print "<tr>\n";
foreach ($row as $item) {
print " <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "</td>\n";
}
print "</tr>\n";
}
print "</table>\n";
oci_free_statement($stid);
oci_close($conn);
?>
我的代码显示包含表格的主体而没有表格标题。
答案 0 :(得分:0)
假设表头应该是显示实际数据的同一个表的一部分,那么你可能想尝试这样的事情。
<?php
echo "
<table>
<tr>
<th>NUME</th>
<th>DECEDATI</th>
<th>RANITI</th>
<th>DISPARUTI</th>
<th>CLADIRI DISTRUSE</th>
<th>DURATA</th>
<th>MAGNITUDINE</th>
<th>ADANCIME</th>
<th>PAGUBE MATERIALE</th>
<th>NUMAR REPLICI</th>
</tr>";
$conn = oci_connect('student', 'STUDENT', 'localhost/XE');
if( !$conn ) {
$e = oci_error();
trigger_error( htmlentities( $e['message'], ENT_QUOTES ), E_USER_ERROR );
}
$stid = oci_parse( $conn, "SELECT * FROM nepal ORDER BY ".$_GET['categorie']." ".$_GET['ordine'] );
if( !$stid ) {
$e = oci_error( $conn );
trigger_error( htmlentities( $e['message'], ENT_QUOTES ), E_USER_ERROR );
}
// Perform the logic of the query
$r = oci_execute( $stid );
if( !$r ) {
$e = oci_error( $stid );
trigger_error( htmlentities( $e['message'], ENT_QUOTES ), E_USER_ERROR );
}
// Fetch the results of the query
while( $row = oci_fetch_array( $stid, OCI_ASSOC+OCI_RETURN_NULLS ) ) {
$value=$item !== null ? htmlentities( $item, ENT_QUOTES ) : " ";
echo "
<tr>
<td>$value</td>
</tr>";
}
oci_free_statement( $stid );
oci_close( $conn );
echo "</table>";
?>
答案 1 :(得分:-1)
print "<table";
需要
print "<table>";
请注意缺少的>