MySQL fetch_assoc() shows 1 less result
问题 i have a table like below: hub dep A B A C B D B E B F E G i use mysql select to get query and my code is like below: $sql = "SELECT dep FROM handd WHERE hub='B'"; $result = $conn->query( $sql ); $row = $result->fetch_assoc(); while($row = $result->fetch_assoc()) { echo "id: " . $row["dep"]."<br>"; } but it just gives me result like below: id: E id: F and i am wondering where is D? 回答1: $row = $result->fetch_assoc(); This line stores the result of 'B D'. It actually should be: $sql = "SELECT