I am adding a search input and button to my website using PDO, my else statement works and I receive 'no results'. However my while statement seems to have no response. Am I missing anything or have I written something wrong in my code?
if(isset($_POST['submit'])){
$search = $_POST['search'];
$articles = $db->prepare("SELECT * FROM articles WHERE headline = :search");
$articles->execute(array(':search' => $search));
if($articles -> rowCount() > 0) {
while ($rows = $articles->fetchAll(PDO::FETCH_ASSOC)){
$headline = $rows['headline'];
echo "headline: $headline<br>";
}
} else{
echo "No Results";
}
}