我正在尝试将数据从数据库显示到Web浏览器,但页面上显示的文本是分散的数据,应该格式化为数据库.. plz帮助如何从数据库中获取和显示数据到网页....
在网页上显示结果后显示结果.... In browser
预期的结果是明智的或格式化的,在数据库中是这样的 original data in database
'<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
</style>
</head>
<body>
<?php
$servername='localhost';
$username='root';
$password='root';
$dbname='export';
// Create connection
$conn=new mysqli($servername,$username,$password,$dbname);
// Check connection
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM csvtbl";
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
echo "<table><tr><td>toc<td></tr>";
// output data of each row
while($row = $result->fetch_assoc())
{
echo "<tr> <td>" . $row["toc"]. "</td></tr>";
}
}
else
{
echo "0 results oops NO data in table !!!!";
}
$conn->close();
?>'