我正在尝试table form
用database
. 它不显示表格,而是打印出第一个带有“无法显示列”的行。至少它应该在浏览器上显示表格形式。MySQL
PHP
job_order_number
database
job_order_number
CSS
<style>
table.db-table {
border-right:1px solid #ccc;
border-bottom:1px solid #ccc;
}
table.db-table th {
background:#eee;
padding:5px;
border-left:1px solid #ccc;
border-top:1px solid #ccc;
}
table.db-table td {
padding:5px;
border-left:1px solid #ccc;
border-top:1px solid #ccc;
}
</style>
PHP
<?php
// connect to the MySQL database
require("connect.php");
if(isset($_POST['submit'])){
$_POST['category_code'] = mysql_real_escape_string($_POST['category_code']);
$sql = "SELECT * FROM CS_JOBS WHERE category_code =".$_POST['category_code'];
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
$table = $row[0];
echo '<h3>'.$table.'</h3>';
$result2 = mysql_query('SHOW COLUMNS FROM '.$table) or die('Cannot show columns from '.$table);
if(mysql_num_rows($result2)) {
echo '<table cellpadding="0" cellspacing="0" class="db-table">';
echo '<tr><th>Job Order Number</th><th>New Job</th><th>Job Title</th><th>Location</th><th>Close Date</th><th>Category_code</th></tr>';
}
while($row2 = my_sql_fetch_row($result2)) {
echo '<tr>';
foreach($row2 as $key => $value) {
echo '<td>'.$value.'</td>';
}
echo '</tr>';
}
echo '</table><br />';
}
}
?>