English 中文(简体)
PHP 树木
原标题:PHP Tree Paging

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

ID, 类别名称,父母类别

页: 1

页: 1

页: 1

4, A1, 1

页: 1

6 A12, 4

等等。

我能够以树木结构的形式表明这一点。 但是,我希望以木制成树结构。

类似,

有1,000个类别。

每页有20个记录(如树木结构)。

So, no. of pages = 50

现在,当用户点击第2页时,应当从Hierarchical大树结构的第21号记录中看到他。

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

请帮助我如何做到这一点。

感谢。

问题回答

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.)

因此,据我称,我必须在每个网页上建立一个等级结构,只显示一些记录(在纸上)。 这种方法需要很长的时间。

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.

是否还有其他解决办法。

感谢。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签