我不知道为什么,但它忽略了表格的第一行。 请帮忙:
$row = 0;
$con = mysqli_connect("localhost", "root", "root", "db");
$query = "select * from user_accounts";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_assoc($result);
while($row = $result->fetch_array())
{
echo $row['ID'] . " " . $row['Username'];
echo "<br />";
}
答案 0 :(得分:4)
有两件事,你要声明一个不需要的变量($row = 0;
)并且你要取两次,你不应该这样做:
$con = mysqli_connect("localhost", "root", "root", "db");
$query = "select * from user_accounts";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_assoc($result))
{
echo $row['ID'] . " " . $row['Username'];
echo "<br />";
}
答案 1 :(得分:2)
$row = mysqli_fetch_assoc($result);
while($row = $result->fetch_array())
因此,您获取一个,忽略它然后继续提取