PDO Select语句不返回任何内容(FETCH_ASSOC)

I'm trying to retrieve records from the mySQL-database but nothing gets selected. I'm using the below php function:

function printButton($conn){
$your_variable = 1;
$knappar = $conn->prepare('SELECT * FROM knappar WHERE pid  < :parameter');
$knappar->bindParam(':parameter', $your_variable, PDO::PARAM_INT);
$knappar->execute();

            //Loops boxes
          $count = 1;
          while ($row = $knappar->fetch(PDO::FETCH_ASSOC)) {
            echo "<a href='#'><div class='box' id='div_item".$count."'>";
            echo $row['header'];
            echo $row['id'];

            echo "</div></a>";
            $count = $count + 1;
            }

}

It works fine if I change "WHERE pid = 1" instead of the "< :parameter". What am I doing wrong?

I updated it to what it looks like now:

function printButton($conn){
$your_variable = 1;
$knappar = $conn->prepare('SELECT header FROM knappar WHERE pid < :parameter');
$knappar->bindParam(':parameter', $your_variable, PDO::PARAM_INT);
$knappar->execute();

            //Loops boxes
      $results = $knappar -> fetchAll(PDO::FETCH_ASSOC);
      foreach ($results as $row){

      echo $row['header'];
      echo '<br />';

      }

}

With above example, still no output. pid value is int(11) in the database and the value of all rows are 1.

$knappar -> fetch(PDO::FETCH_ASSOC) only fetches the next row of the result set. Use fetchAll to get the entire result set.

You could then iterate through the returned array with a foreach.

Granted, I'm not sure why it returns nothing rather than just the first row but give it a try.