Display table data with php & mysqli

I am trying to display data from my table on my page, and I have done this many times before. This time it does not work, I usually copy the code from my other projects and change the corresponding values, but this time it does not work. Please note that I am not quite sure what I am doing. I usually don’t write code. This is using iis with php and the database server is mysql. The problem is that I get a white page without errors or other signs.

Here is the code.

<?php
require('connection.php');

$sql = "SELECT * FROM td";

$result = mysqli_query($con,$sql)or die(mysqli_error());

echo "<table>";
echo "<tr><th>Date</th><th>Comment</th><th>Amount</th></tr>";

while($row = mysqli_fetch_array($result)) {
    $date = $row['date'];
    $comment = $row['comment'];
    $amount = $row['amount'];
    echo "<tr><td style='width: 200px;'>".$date."</td><td style='width: 600px;'>".$comment."</td><td>".$amount."</td></tr>";
} 

echo "</table>"
mysqli_close($con);
?>

Oh, and there is data in the table. In addition, connecting to db is fine. I use the same join file to insert data into a table.

Wow, that fixed it. I knew that it was some kind of stupidity on my part, I just noticed it.

+4
1
echo "</table>";

";": D. , , , ? , .

+4

Source: https://habr.com/ru/post/1537405/


All Articles