php - Count starts at 2 -
i don't know why disregards first row of table. please help:
$row = 0; $con = mysqli_connect("localhost", "root", "root", "db"); $query = "select * user_accounts"; $result = mysqli_query($con, $query); $row = mysqli_fetch_assoc($result); while($row = $result->fetch_array()) { echo $row['id'] . " " . $row['username']; echo "<br />"; }
two things, you're declaring un-needed variable ($row = 0;
)and you're fetching twice, shouldn't do:
$con = mysqli_connect("localhost", "root", "root", "db"); $query = "select * user_accounts"; $result = mysqli_query($con, $query); while($row = mysqli_fetch_assoc($result)) { echo $row['id'] . " " . $row['username']; echo "<br />"; }
Comments
Post a Comment