Please help with pagination

Discussion in 'PHP' started by carl_in_florida, Aug 23, 2007.

  1. #1
    Here is the code for my pagination code in a script i am using, it has th next and prev but no page numbers. Can you help me add this?

    echo "<br><br><h2>Browse By author</h2>";
    mysql_connect($server, $user, $pass) or
    die("Could not connect: " . mysql_error());
    mysql_select_db($dbname);
    if($_GET['offset'] == "") {
    $result = mysql_query("SELECT DISTINCT author FROM ".$table." WHERE letter = '".$_GET['letter']."' LIMIT ".$pagelimit."");
    } else {
    $result = mysql_query("SELECT DISTINCT author FROM ".$table." WHERE letter = '".$_GET['letter']."'  LIMIT ".$pagelimit."  OFFSET ".$_GET['offset']." ");
    }
    if($_GET['offset'] != "" && $_GET['offset'] > 20) {
    echo "<font size=2><a href='author-".$_GET['letter']."-".($_GET['offset'] - $pagelimit)."'><- prev</a></font> ";
    }
    if(($_GET['offset'] + $pagelimit) < $countofauthor) {
    echo "<font size=2><a href='author-".$_GET['letter']."-".($_GET['offset'] + $pagelimit)."'>next -></a></font> ";
    }
    echo "<br><br>";
    while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
    echo "<br><a href='browse-".$row['author']."'>".$row['author']."</a>";
    }
    PHP:
     
    carl_in_florida, Aug 23, 2007 IP