`$results = intval($_POST['results']);` seems to be common to the `else if` and `else` case.
Thus, I would make it an

    if(!isset($_POST['first']) || is_null($_POST['first'])){
      …
    } else {
      $first = intval($_POST['first']);
      if ($first < 0) {
        $first = 0;
      }
      $results = intval($_POST['results']);
    }