Sets of 25 with PHP and MySQL -


what i'm trying accomplish is,

  1. add list of words separate entries table.
  2. display words in group of 25. if there 25 entries, 1-25 shown in list. also, if there 27 entries, number 26 , number 27 show. not last 25 entries table.

i know how insert , pull information database, not know how proper grouping them in groups of 25.

edit: how increase limit automatically based on number of rows in table?

edit #2: question not duplicate. not want recent 25. want them in groups of 25. question answered below.

imho can't in 1 query (at least in standard sql in readable way).

you need:

  1. get number of entries in table (assuming table named tbl1):

    select count(*) tbl1; 
  2. get number of entries not-selected using integer division. exact code depends on language use. example on php (assuming result of step 1 stored in $count):

    $offset = floor($count/25); //or: $offset = $count - $count%25; 
  3. extract needed entries using limit:

    select * tbl1 order <specify-order-here> limit 25 offset <insert-$offset-here>; 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -