Visualizzazione dei risultati da 1 a 6 su 6

Discussione: database

  1. #1

    database

    ciao, ho un databse dove ho nella tabella ho dei record, ho un id che è autoincrement, ovvero all'inserimento di un record aumenta di 1.

    il problema è che visualizzo tutti i record su una pagina e così va a finire che se i record sono 50, vedo 50 record su un pagina. c'è la possibilità, magari attraverso id, di fare più pagine con visualizzati solo 5 record per pagina?

    ciao ciao!

  2. #2
    Utente di HTML.it L'avatar di gianiaz
    Registrato dal
    May 2001
    Messaggi
    8,027
    The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must be integer constants. With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):

    mysql> SELECT * FROM table LIMIT 5,10; # Retrieve rows 6-15

    For compatibility with PostgreSQL, MySQL also supports the LIMIT row_count OFFSET offset syntax. To retrieve all rows from a certain offset up to the end of the result set, you can use some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:

    mysql> SELECT * FROM table LIMIT 95,18446744073709551615;

    With one argument, the value specifies the number of rows to return from the beginning of the result set:

    mysql> SELECT * FROM table LIMIT 5; # Retrieve first 5 rows

    In other words, LIMIT n is equivalent to LIMIT 0,n.
    per maggiori info:

    http://dev.mysql.com/doc/mysql/en/SELECT.html

  3. #3
    con questo:

    mysql> SELECT * FROM table LIMIT 5,10; # Retrieve rows 6-15

    ho visto mi mette solo le prime 5, per le altre?

  4. #4
    Originariamente inviato da pboscolo
    con questo:

    mysql> SELECT * FROM table LIMIT 5,10; # Retrieve rows 6-15

    ho visto mi mette solo le prime 5, per le altre?
    metti dei link passando come parametro il numero del record dal quale partire e ti costruisci le query.

  5. #5
    allora ne visulaizzo 5 per pagina, ma se io ne ho meno di 5 non mi servono i link e se ne ho più di 5 mi servono non so se capite, però non posso modificare il prg una volta sul server, resta la, quindi servirebbe che per i primi 5 non ci fossero link alle altre pagine, mentre se sono più di 5 ci fossero link alle altre pagine!

    qlcn mi aiuta????





  6. #6

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.