I am having an issue where I am doing a query and it is coming back with about 100 pages, I was hoping to have it come back with 1,2,3...30,31...99,100 instead of 1,2,3,4,5,6,7,8,etc. please see below for working code that returns back results as unwanted format, I am new here so if this question is written wrong please let me know and I will make necessary changes , thanks in advance:function getPage($stmt, $pageNum, $rowsPerPage){$offset = ($pageNum - 1) * $rowsPerPage;$rows = array();$i = 0;while(($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_NUMERIC,  SQLSRV_SCROLL_ABSOLUTE,         $offset + $i)) && $i < $rowsPerPage){array_push($rows, $row);$i++;}return $rows;}// Set the number of rows to be returned on a page.$rowsPerPage = 30;// Connect to the server.$serverName = 'test';$connOptions = array(Database=>test);$conn = sqlsrv_connect($serverName, $connOptions);if (!$conn)die( print_r( sqlsrv_errors(), true));//  Define and execute the query.  // Note that the query is executed with a scrollable cursor.$sql = select * from info;$stmt = sqlsrv_query($conn, $sql, array(), array( Scrollable => 'static' ));if ( !$stmt )die( print_r( sqlsrv_errors(), true));// Display the selected page of data.echo <table border='1px' align='center'>;$pageNum = isset($_GET['pageNum']) ? $_GET['pageNum'] : 1;$page = getPage($stmt, $pageNum, $rowsPerPage);foreach($page as $row)echo <tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td></tr>;echo </table>;?><table align='center'><?php// Get the total number of rows returned by the query.// Display links to pages of rows.$rowsReturned = sqlsrv_num_rows($stmt);if($rowsReturned === false)die( print_r( sqlsrv_errors(), true));elseif($rowsReturned == 0){echo No rows returned.;exit();}else{     // Display page links.$numOfPages = ceil($rowsReturned/$rowsPerPage);for($i = 1; $i<=$numOfPages; $i++){ $pageLink = ?pageNum=$i; print(<a href=$pageLink>$i</a>&nbsp;&nbsp;);}echo <br/><br/>;}    sqlsrv_close( $conn );
PHP Pagination for 1,2,3... vs 1,2,3,4,5,etc
php;sql;pagination
Do you just mean the links at the bottom of your page? If so you have this code:// Display page links.$numOfPages = ceil($rowsReturned/$rowsPerPage);for($i = 1; $i<=$numOfPages; $i++){    $pageLink = ?pageNum=$i;    print(<a href=$pageLink>$i</a>&nbsp;&nbsp;);}Modify this to render just  the first three links, then your ellipses (...) separator and then the final page number.EDIT to add pseudo codeThis is messy but hopefully gives you the idea, create your function, make it work and then post a new question asking how to make it prettier (for example tidy up the ifs, add logic to only render a single set of ellipses, don't repeat any rendering code).$numOfPages = ceil($rowsReturned/$rowsPerPage);$renderedEllipses = false;for($i = 1; $i<=$numOfPages; $i++){    //If you always want to render pages 1 - 3    if($i < 4) {        //render link    }    //If you always want to render current page number    else if($i == $pageNum) {        //render link        //reset ellipses        $renderedEllipses = false;    }    //if you always want the last page number    else if ($i == $numOfPages - 1) {        //render link    }    //make sure you only do this once per ellipses group    else {      if (!$renderedEllipses){          print(...);          $renderedEllipses = true;      }    }}EDIT added ellipses testThe $renderedEllipses flag will stop hundreds of ellipses being rendered.