Reputation: 341
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?
Upvotes: 0
Views: 1241
Reputation: 775
$row = $result->fetch_assoc();
This line stores the result of 'B D'. It actually should be:
$sql = "SELECT dep FROM handd WHERE hub='B'";
$result = $conn->query( $sql );
while($row = $result->fetch_assoc()) {
echo "id: " . $row["dep"]."<br>";
}
Upvotes: 1