PHP array problem, retrieve the PHP array problem before the multi-dimensional array, and retrieve the dimension before the multi-dimensional array.
Array ([0] => Array ([username] => test2222 [id] => 66) [1] => Array ([username] => test [id] => 64) [2] => Array ([username] => test [id] => 62) [3] => Array ([username] => aaa [id] => 61), paging is required. On the first page, $ key is used for normal display, 0-9. The next page should be 10-19, or 0-9, the same as the first page.
Reply to discussion (solution)
Talk about your practice
Talk about your practice
I am using thinkphp, and the background $ this-> assign ('list', $ list), $ list is the multi-dimensional array. The foreground page uses the volist loop, $ vo. id and $ vo. username. The id and name are displayed. Use $ key to create the sequence number of the table. The first page is normal, 0-9, but the page is displayed, the second page, and the third page are the same as the first page, and it is also 0-9. It should show him 10--29.
The first is the first page, the second is the second page, and the latter is the same
I am using thinkphp, and the background $ this-> assign ('list', $ list), $ list is the multi-dimensional array. The foreground page uses the volist loop, $ vo. id and $ vo. username. The id and name are displayed. Use $ key to create the sequence number of the table. The first page is normal, 0-9, but the page is displayed, the second page, and the third page are the same as the first page, and it is also 0-9. It should show him 10--29.
Does it perform paging with the database?
I am using thinkphp, and the background $ this-> assign ('list', $ list), $ list is the multi-dimensional array. The foreground page uses the volist loop, $ vo. id and $ vo. username. The id and name are displayed. Use $ key to create the sequence number of the table. The first page is normal, 0-9, but the page is displayed, the second page, and the third page are the same as the first page, and it is also 0-9. It should show him 10--29.
Does it perform paging with the database?
Well, the page is displayed. if the page is not displayed, you can use $ key. However, if the page is displayed, each page is the same.
I am using thinkphp, and the background $ this-> assign ('list', $ list), $ list is the multi-dimensional array. The foreground page uses the volist loop, $ vo. id and $ vo. username. The id and name are displayed. Use $ key to create the sequence number of the table. The first page is normal, 0-9, but the page is displayed, the second page, and the third page are the same as the first page, and it is also 0-9. It should show him 10--29.
Does it perform paging with the database?
I now want to use $ key + page number * to display the number of lines per page. now I don't know how to get the number of pages per page. I use the page that comes with thinkphp.
$ Key is only the current $ list de serial number
According to what you mean, the page number * is calculated based on the number of page lines + $ key.
$ Key is only the current $ list de serial number
According to what you mean, the page number * is calculated based on the number of page lines + $ key.
Well, now I think of this method.
$ Key is only the current $ list de serial number
According to what you mean, the page number * is calculated based on the number of page lines + $ key.
In the thinkphp page, the current page is nowPage. I use $ nowPage and cannot find it. I use $ this-> assign ('nowpage', $ nowPage) in the background, and $ nowPage cannot be found.
I thought it would be much easier to put the serial number in $ list.
I thought it would be much easier to put the serial number in $ list.
Well, but I don't know how to retrieve the dimension before the multi-dimensional array,
Array ([0] => Array ([username] => test2222 [id] => 66) [1] => Array ([username] => test [id] => 64) [2] => Array ([username] => test [id] => 62) [3] => Array ([username] => aaa [id] => 61 ))
I don't know how to retrieve 0, 1, 2, 3
Array_keys ($ list)
Generally, the sequence number does not start from 0, but is used to starting from 1.
If $ pageoffs is the starting sequence number
Foreach ($ list as & $ r) $ r ['sequence number '] = $ pageoffs ++; $ this-> assign ('list', $ list );
Array_keys ($ list)
Generally, the sequence number does not start from 0, but is used to starting from 1.
If $ pageoffs is the starting sequence number
Foreach ($ list as & $ r) $ r ['sequence number '] = $ pageoffs ++; $ this-> assign ('list', $ list );
This method is correct. Locate the problem. it turns out to be a thinkphp page. you can only query the current page for each query.