我写了一个脚本而且它没有提取数据,我看不出它有什么问题。
我的脚本是:
<?php
$conn = mysqli_connect("*****", "*****", "*****", "*****");
$sql = "SELECT * FROM points ORDER BY points DESC LIMIT 3;";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo $row['players'] . "<br>";
}
}
?>
答案 0 :(得分:0)
从数据库中获取数据的代码工作正常,您应该检查数据库名称或表名称或表的字段名称。并且可能发生在您的表中不存在您尝试获取的表的字段名称。
<?php
$conn = mysqli_connect('localhost','root','','stackoverflow');
$sql = "SELECT * FROM task ORDER BY task_id DESC LIMIT 3 ;";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0)
{
while ($row = mysqli_fetch_assoc($result)) {
echo $row['license'] . "<br>";
}
}
?>