The following is the script I'm using to display all data in a table. All of the table row data displays in their own rows. There are two problems:
1. The header cell row section should be seen only once. Right now it is repeated above each row displayed. Where do I put the info so it displays just once?
2. Each row displays in its own table, with the header cells repeating at top once for each row. As a consequence, the table columns are not lined up, making it hard to read. How do I get the info to all display in the same table?
The script is based loosely on Kevin Yanks' Build Your Own DB Driven Website book
Thanks!
Steve
PHP Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SPOTLIGHT_VEH TABLE
<meta http-equiv="content-type"
content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="associatedcss.css">
</head>
<body>
<h1>SPOTLIGHT_VEH TABLE</h1>
<?php
require_once ('connect.php');
?>
<?php
$sv = @mysql_query('SELECT DISTINCT id, vehicle_name, descr, year, photoid, filename, conversion FROM spotlight_veh');
if (!$sv) {
exit('<p>Unable to obtain spotlight_veh data from the database.</p>');
}
?>
<?php
while ($asv = mysql_fetch_array($sv)) {
echo "<table class='chart800'><tr>";
echo "<td class='headercell'><p>id</p></td>";
echo "<td class='headercell'><p>vehicle_name</p></td>";
echo "<td class='headercell'><p>owner_name</p></td>";
echo "<td class='headercell'><p>descr</p></td>";
echo "<td class='headercell'><p>year</p></td>";
echo "<td class='headercell'><p>photoid</p></td>";
echo "<td class='headercell'><p>filename</p></td>";
echo "<td class='headercell'><p>conversion</p></td></tr>";
$aid = $asv['id'];
$avname = htmlspecialchars($asv['vehicle_name']);
$aoname = htmlspecialchars($asv['owner_name']);
$adescr = htmlspecialchars($asv['descr']);
$ayear = $asv['year'];
$apid = $asv['photoid'];
$afilename = htmlspecialchars($asv['filename']);
$aconv = htmlspecialchars($asv['conversion']);
echo "<tr><td class='row1'><p>$aid</p></td>";
echo "<td class='row1'><p>$avname</p></td>";
echo "<td class='row1'><p>$aoname</p></td>";
echo "<td class='row1'><p>$adescr</p></td>";
echo "<td class='row1'><p>$ayear</p></td>";
echo "<td class='row1'><p>$apid</p></td>";
echo "<td class='row1'><p>$afilename</p></td>";
echo "<td class='row1'><p>$aconv</p></td>";
}
?>
</tr></table>
<p><a href="index1.php">Return to front page</a></p>
<p><a href="spotlight_select.spotlight_veh.php">Refresh page</a></p>
</body>
</html>





Bookmarks