my $q = new CGI; my $page = $q->param("page") || '0'; #default 0 my $count = $q->param("count") || 15; # more flexibility. you can pass the No of records as count :), defaults to 15 $offset = $page * count; # assumes that page no starts with 0. #$offset = ($page-1) * count; # assumes that page no starts with 1. Comment previous line and uncomment this if you wish to start page from 1 $SQL = "SELECT * FROM your_table ORDER BY id LIMIT $offset, $count"; ... ...