English 中文(简体)
Codeigniter Pagination over array instead of Database resultset
原标题:

I have looked into trying to use the pagination class within codigniter but for my problem I need to paginate over an array of data and not a database table. In my code I create a custom array and then pass that array to the view using the standard

$this->load->vars($myarray);
$this->load->view( myview , $myarray);

Everything works fine in that sense but the $myarray at times can be really large. I really want to try and create some sort of pagination on the view that will only dislpay the first 25 of the array but the more I read about the Pagination class within codeigniter it looks like you can only paginate over database tables. Does anyone know how I might achieve this? Thanks

问题回答

Can t you just slice up the array yourself before loading it into the view?

http://us3.php.net/array_slice Give array_slice the page offset and result count and it will basically do exactly what you want.





相关问题
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 ...

热门标签