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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -