More simplified way of creating page links dynamically?
This:

$count = 1;
for($i = 1; $i &lt;= $num; $i++) {
    if(($i%$npp) === 0) {
        $count++;
    }
}


is equivalent to

$count = floor($num / $npp) + 1;


As for the paging, I'd do it like this:

$from = $page - $half;
if ($from &lt;= 2) $from = 2;
$to = $page + $half;
if ($to &gt;= $count - 1) $to = $count - 1;

$extra = $query . $by;
$links = $this-&gt;pageLink(1, $extra);
if ($from &gt; 2) $links .= "...";
for ($i = $from; $i &lt;= $to; $i++)
    $links .= $this-&gt;pageLink($i, $extra);
if ($i &lt; $count) $links .= "..."; // I use $i instead of $to because $i == $to + 1, so I save one addition
$links = $this-&gt;pageLink($count, $extra);


Here, you also need:

private function pageLink($num, $extra) {
    return '&lt;a href="search.php?page=' . $num . $extra . '" class="tableLink"&gt;' . $num . '&lt;/a&gt;';
}


This was written by heart, so be weary of the possible bugs.