使用php&显示表数据mysqli的 [英] Displaying table data with php & mysqli

查看:83
本文介绍了使用php&显示表数据mysqli的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的页面上显示我的表格中的数据,之前我已经做了很多次。这次它不起作用,我通常从我的其他项目复制代码并更改适当的值,但这次它不起作用。请注意我不太确定我在做什么。我通常不会编写代码。这是使用iis与PHP和数据库服务器是mysql。问题是我得到一个没有错误或其他标志的白页。

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.

这是代码。

<?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. 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.

推荐答案

echo "</table>";

你忘了; :d。如果这没有帮助,也许结果是空的,没有什么可以显示的?这可能就是你有白屏的原因。

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.

这篇关于使用php&amp;显示表数据mysqli的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆