Last active
September 5, 2015 12:58
-
-
Save lon9/6c149c26a5c59b11355d to your computer and use it in GitHub Desktop.
Webページのページングの時に必要になる超簡単なアルゴリズム ref: http://qiita.com/Rompei/items/cc4ca6cffa2fd3c3930a
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p:ページナンバー | |
m:1ページに表示したい項目数 | |
問:sql文を作成したい=>SQLのl:Limitとo:Offsetを求める。また、初期値としてそれぞれl=M,o=0とする。 | |
アルゴリズム: | |
l=m | |
o=(p-1)*l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n:全項目数 | |
p:ページナンバー | |
m:1ページに表示したい項目数 | |
問:そのページが最後のページか判定したい。 | |
例:例えば、最後のページでは「次へ」などのインジケータを消したい。 | |
アルゴリズム: | |
if n-m*p<=0 then | |
return true | |
else | |
return false | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment