How to browse results with php mssql?

I’m working with php and I want to do a next button that’s step to the next 10 records (like when you browse question with stackoverflow)
I don’t know how to do that but I’m thinking to do it with Top n record ? Do you think that’s a good idea ? Any suggestion?

  • Return DB results within Date Range
  • Long time to load first sql connection in .NET
  • Concatenate multiple rows
  • Dynamic Pivot Table in SQL Server
  • How To Create Generic SQL Server Stored Procedure To Perform Inserts Into Audit Table Based on Inserted and Deleted In Trigger
  • integer Max value constants in SQL Server T-SQL?
  • The EXECUTE permission was denied on the object 'xxxxxxx', database 'zzzzzzz', schema 'dbo'
  • How to I force lock escalation (to flush out deadlock issues) during testing?
  • ssrs 2008 passing a parameter list to a subreport
  • What is the difference between JAVA date format “dd/MM/yyyy” and “dd/mm/yyyy”?
  • How to sum up time field in SQL Server
  • Microsoft® ODBC Driver 11 for SQL Server® on RedHat Linux with PHP - gives an error when bind parameter with PDO for stored procedures
  • 6 Solutions collect form web for “How to browse results with php mssql?”

    As for doing it in PHP, you can easily make the button send a POST or GET request for the starting amount. For instance, a user would make the initial request and that is just yoursite.com/search.php, and the next button would send them to the same page with the same search criteria only send an additional field of “start”, (i.e. yoursite.com/search.php?start=10). And in the code, you can simply check for it:

    if(isset($_POST['start'])) {
        //code to add to the search string to start at $_POST['start']
    }
    

    Edit 1: This article is the best I could find as to how to replicate MySQL’s LIMIT function. Also, this one has a more definitive query to reference, but it’s the same idea.

    I know in MySQL you can use LIMIT X, Y where X is the lower bound of the return and Y is the upper bound. So if you wanted to return 10-20 you would use LIMIT 10, 20. Not sure what the MS-SQL equivalent is.

    doesn’t mssql have something like LIMIT in mysql? so you could do:

    select xxx from yyy LIMIT 0,10
    

    for first 10 results, then do LIMIT 10,20 for next 10 results etc.

    You can use MySQL’s limit

    Set a variable called:

    $limit = 10;
    $pl = $_GET["page"] * $limit;
    if(!isset($_GET["page"]) || $_GET["page"] == 1)
    {
        $pl = 0;
    }
    

    and in your query do

    $sql = sprintf("SELECT * FROM table LIMIT %d,%d" 
    mysql_real_escape_string($pl),
    mysql_real_escape_string($limit));
    

    Btw this is from memory but i think it works.

    Would this be any help to you?

    $count=$_POST[page]*10;
    

    for MySQL:

    $rowsPerPage = 10;
    $offset = ((int)$_GET['page'] - 1) * $rowsPerPage;
    
    $result = mysql_query(
        sprintf('select xxx from yyy LIMIT %d,%d', $offset, $rowsPerPage)
    ); 
    
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.