から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 />';
}
}
?>