Changing a php while loop to foreach [closed]


I'm new to PHP and still getting used to the syntax. Would anyone be able to tell me how I could re-write this block as a foreach instead of a while loop please?

When running an SQL query that would return two rows I'm only getting one and I'm thinking it's to do with the type of loop that I'm using.

I'm having trouble getting syntax that works.

$stmt = $conn->prepare("SELECT * FROM `staff_details` WHERE first_name='{$_POST['firstname']}' AND surname='{$_POST['lastname']}'");  fetch(PDO::FETCH_ASSOC) ) { ?>            

Thank you

$stmt = $conn->prepare("SELECT * FROM `staff_details` WHERE first_name= ? AND surname= ?");  $stmt->execute(array($_POST['firstname']