I'm trying for a search function, I made a public function in a file called Topic, and I tried calling the method in the index.php, however it doesn't show anything, I think the problem lies with the while statement, but i'm not entirely sure.
Topic.php
class Topic{
public function searchPosts($postTags)
  {
    $conn = Db::getInstance();
   $statementSearch = $conn->prepare("SELECT * FROM topics INNER JOIN posttopic ON topics.topicID=posttopic.topicID INNER JOIN posts ON posttopic.postID=posts.postID WHERE naam = :naam");
   $statementSearch->bindValue(":naam", $postTags);
   return $statementSearch->execute(array());
  }
}  
Index.php
    spl_autoload_register(function ($class) {
    include_once("classes/" . $class . ".php");
    });  
$_SESSION['KEYWORD'] = array();
$postArray = array();
//$allResults2 = array();
if (isset($_POST['Find'])) {
if (!empty($_POST['Find'])) {
    $searchTopic = new Topic();
    $postTags = $_POST['naam'];
    $searchTopic->searchPosts($postTags);
    while ($row = $statementSearch->fetch(PDO::FETCH_ASSOC)) {
        $_SESSION['KEYWORD'][] = $row['postImageUrl'];
        $postArray[] = $row['postID'];
    }
}
if (count($_SESSION['KEYWORD']) === 0) {
    $error = "Sorry no results!";
}
}
This is the html where it should be printed.
        <?php
        foreach (array_combine($_SESSION['KEYWORD'], $postArray) as           $imageLink => $i) {
            echo "<a href='./pin.php?postid=$i' ><img src='" . $imageLink . "'</a>";
        }
        ?>
