0

hello,

i have a mysql vehicle database with 5 fields: make, model, price, year and chasis no which is being searched by a php script to display user queries. script is working fine but i need to display the data in a table for better presentation.
help greatly appreciated

regards,
mike

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by diafol
0
$q = "SELECT ..."
$result = mysql_query($q);
echo "<table>\n\t<thead>\n\t\t<tr>\n\t\t\t<th>Model</th>\n\t\t\t<th>Make</th>\n\t\t\t<th>Price</th>\n\t\t\t<th>Year</th>\n\t\t\t<th>Chassis</th>\n\t\t</tr>\n\t</thead>\n\t<tbody>";

while($data = mysql_fetch_array($result)){
   echo "\n\t\t<tr>\n\t\t\t<td>{$data['model']}</td>\n\t\t\t<td>{$data['make']}</td>\n\t\t\t<td>{$data['price']}</td>\n\t\t\t<td>{$data['year']}</td>\n\t\t\t<td>{$data['chassis']}</td>\n\t\t</tr>"; 
} 

echo "\n\t</body>\n</table>";

You could write the first and last bits in just plain HTML rather than generate it through php. The '\n' creates a new line and the \t creates a tab. It's just a way of presenting the html in a tidy format.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.