how do i FORMAT OUTPUT from php-mysql database
Posted: Fri Mar 14, 2014 5:53 am
Hi
i got a php code on internet that works fine. It retrieves details of suppliers from a mysql table "suppliers". All column headings are displayed horizontally.
It retrieves data and displays as shown below:
ID | NAME | ADDRESS | PLACE | PHONE | EMAIL
----------------------------------------------------------------
1 | TOM | XYZ | ABC | 123 | FDS@FDSF.COM
However i would like to format the output to appear as shown below in image file "desired-output.png":
I want all my column headings to appear in one column (vertically) as shown above and subsequent columns will contain matching related data about suppliers. Being a newbie im unable to do it.
my table.php file is below:
can someone help me and point me in the right direction ?
thanks in advance
i got a php code on internet that works fine. It retrieves details of suppliers from a mysql table "suppliers". All column headings are displayed horizontally.
It retrieves data and displays as shown below:
ID | NAME | ADDRESS | PLACE | PHONE | EMAIL
----------------------------------------------------------------
1 | TOM | XYZ | ABC | 123 | FDS@FDSF.COM
However i would like to format the output to appear as shown below in image file "desired-output.png":
I want all my column headings to appear in one column (vertically) as shown above and subsequent columns will contain matching related data about suppliers. Being a newbie im unable to do it.
my table.php file is below:
Code: Select all
<?php
$con=mysqli_connect("127.0.0.1","root","","supplier");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM supplier");
echo "<table class='search' >
<tr>
<th>ID</th>
<th>NAME</th>
<th>ADDRESS</th>
<th>PLACE</th>
<th>PHONE</th>
<th>EMAIL</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['ID'] . "</td>";
echo "<td>" . $row['NAME'] . "</td>";
echo "<td>" . $row['ADDRESS'] . "</td>";
echo "<td>" . $row['PLACE'] . "</td>";
echo "<td>" . $row['PHONE'] . "</td>";
echo "<td>" . $row['EMAIL'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Form Submission</title>
<!-- This is the CSS file for this tutorial -->
<link href="Articlestyles.css" rel="stylesheet" type="text/css">
</head>
</html>
can someone help me and point me in the right direction ?
thanks in advance