1

i am trying to display data from database to web browser but the text which is displayed on page is scattered data it should be formatted as in database.. plz help how to fetch and display data from database to webpage....

showing result is like this after display on webpage....In browser

Expected result line wise or formatted which in database is like this 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();
?>'
rohit_235
  • 11
  • 1

0 Answers0