$pages = ($total- ($remainder = $total % $perpage) )/$perpage; $pages++ if $remainder;