Display each field in mysql table in separate rows
Posted: Sat Mar 07, 2009 7:45 pm
I have searched exhaustively and not found what I need. Here is my situation.
I need to display mysql data with each field on a separate row. I am currently using a mysql database (bcrattend) with the table (attendees) and fields: name, email, age, date. I use the following to retrieve and display the data:
This displays all the records in columns like this:
Name Email Age Date
data data data data
I am going to change my query so I only display one record and I need to have it displayed as:
Name: data
Email: data
Age: data
Date: data
harleyridin
I need to display mysql data with each field on a separate row. I am currently using a mysql database (bcrattend) with the table (attendees) and fields: name, email, age, date. I use the following to retrieve and display the data:
Code: Select all
<?php
mysql_connect("localhost","name","password");
//if (!$con)
// {
// die('Could not connect: ' . mysql_error());
// }
mysql_select_db("bigcross_bcrattend");
$result = mysql_query("SELECT * FROM attendees order by date");
echo "<table border='1'>
<tr>
<th>Name</th>
<th>Email</th>
<th>Age</th>
<th>Date</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td>" . $row['age'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "</tr>";
}
echo "</table>";
//mysql_close($con);
?>
Name Email Age Date
data data data data
I am going to change my query so I only display one record and I need to have it displayed as:
Name: data
Email: data
Age: data
Date: data
harleyridin
Code: Select all