chromatel chromatel - 3 months ago 32
MySQL Question

Displaying table data with php & mysqli

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

Here is the code.


$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>"

Oh and there is data in the table. Also the connection to the db is fine I use the same connection file to insert data to the table.

Wow that fixed it. I knew it was some stupidity on my part I just did notice it Thanks everyone!

echo "</table>";

you forget the ";" :D. And if that did not help, maybe the result is empty and there's nothing to show? That may be why you got a white screen.