Sets of 25 with PHP and MySQL -
what i'm trying accomplish is,
- add list of words separate entries table.
- 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:
get number of entries in table (assuming table named
tbl1
):select count(*) tbl1;
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;
extract needed entries using limit:
select * tbl1 order <specify-order-here> limit 25 offset <insert-$offset-here>;
Comments
Post a Comment