When I use the following code, it returns nothing - no errors, no values. When I want to select just one specific row and display that data, using fetch() works fine. But the moment I put it in a loop to get multiple rows, nothing happens. Here is the code I am using:
$stmt = $pdo->prepare("SELECT name FROM company WHERE position = :position AND branch = :branch ORDER BY name ASC");
$position = 23;
$branch = "Management";
$stmt->bindParam(':position', $position, PDO::PARAM_INT);
$stmt->bindParam(':branch', $branch, PDO::PARAM_STR);
$stmt->execute();
while ($row = $stmt->fetch()) {
echo $row['name'];
}