我需要做的是獲取$ list中的值以顯示在單獨的列中,並將列的標題顯示在其自己的行中。
if (isset($_POST['check_list'][0])) {
// form was submitted, checkbox was checked
?>
<table>
<table border='1'>
<tr>
<th>Artist</th>
<th>Composer</th>
<th>Genre</th>
<th>Title</th>
<th>Album</th>
<th>Label</th>
<th>Price</th>
<th>Description</th>
</tr>
<tr>
<?php
foreach ($_POST['check_list'] as $item) {
echo '<td>' . $item . '</td>'; // here we add the table row and fill there all data from $getColumn array, each one has own table cell
}
echo '</table>';
} else if (isset($_POST['submit'])) {
// form was submitted, checkbox wasn't checked
echo 'Form was submitted and checked wasn\'t checked';
}
?>
</table>
數據庫頁:
print '<input type="hidden" name="checkbox1" value="'. $getColumn[1].'" />';
print '<input type="hidden" name="checkbox2" value="'. $getColumn[2].'" />';
print '<input type="hidden" name="checkbox3" value="'. $getColumn[3].'" />';
print '<input type="hidden" name="checkbox4" value="'. $getColumn[4].'" />';
print '<input type="hidden" name="checkbox5" value="'. $getColumn[5].'" />';
print '<input type="hidden" name="checkbox6" value="'. $getColumn[6].'" />';
print '<input type="hidden" name="checkbox7" value="'. $getColumn[7].'" />';
print '<input type="hidden" name="checkbox8" value="'. $getColumn[8].'" />';
print '<input type="hidden" name="checkbox8" value="'. $getColumn[9].'" />';
print '<td><input type="checkbox" name="check_list[]"value="'. $getColumn[0].'"</td>';
連接:
$conn = pg_connect("host=**** port=****
dbname=teaching user=csguest password=****);
$res = pg_query ($conn, "SELECT ref, artist, composer, genre, title, album, label, price, description FROM music");
print "<table border='1'>";
print "<th>Check box</th><th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th><th>Price</th><th>Description</th></tr>";
while($getColumn = pg_fetch_row($res))
什麼/你的問題在哪裏? – user3510665 2014-11-22 11:07:50
數據在xhtml表格中無法正確顯示:( – harris 2014-11-22 11:09:05