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

Member Avatar for diafol
$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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.