开发者

PHP Tree Paging

I have a category table with sub-categories Table Structure is:

ID, Category Name, Parent Category

1, A, 0

2, B, 0

3, C, 0

4, A1, 1

5, A2, 1

6, A12, 4

and so开发者_如何学Python on..

I am able to display this in the form of Tree Structure. But I want to display them as Tree Structure with Paging.

Something like,

Say there are 1000 categories.

Every page shows 20 records (in tree like structure)

So, no. of pages = 50

Now, when user clicks on Page Number 2 then he should be shown records from number 21 from the Hierarchical Tree Structure.

So, what I want is that a Tree with Paging.

Please help me in how to do it.

Thanks.


First get the entries which are in the currently selected branch; then cull them according to the offset.

(You are obviously somewhere storing the currently selected branch, and have some means of setting the position in the pages. Make an ordered list of the sub-nodes in the branch to be displayed, then get the subset between $offset and $offset+$numberOfEntriesToBeShown-1 and display these entries.)


So, according to it I have to create a hierarchical structure on every page and show only some records (acc. to paging). By this method it takes long time load.

I have 3000 records in table with Id, Name, Parent Id I now create a tree structure on page 1 (of paging) showing first 10 records from array (of tree structure). Then user goes on 2nd page and again a tree structure is created but records 11-20 are being shown.

So, here every time whole tree is formed first and then only a part is showing. For 3000 records it takes time to create a complete tree every time and in future if there are more records say 10000 or even more then it will even more time.

Is there some other solution to it.

Thanks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜