• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pagination problem.

#11
[eluser]peekk[/eluser]
One more problem, is it possible to listing in our pages, two another $result tables? I.E I have $results1, which contains 50 elements, and $results2 which contains 20 elements. My $per_page parameter is set on 25. So is it possible to make it that, the first two pages will be from $results1 table, and the third from $results2?

#12
[eluser]aquary[/eluser]
Possible? Yes, but maybe in a tricky PHP way...

The pagination would be..
Code:
$config=array(
   'base_url'=>site_url('something/somewhere'),
   'per_page'=>25,
   'total_rows'=>$table1_total+$table2_total
)

Now, the worst part is selecting the data. Since you'll have to determined if the current page is only the table 1, or table 1 with some part of table 2, or only table 2. It's possible, with some logic behind.

OR, you could use UNION in the query to select data from 2 tables at the same time. With some aliasing them to have the same fields name, it might work.

I've never used UNION, so I cannot suggest anything more, but it shouldn't be too hard...

The only problem I could imagine is: the query might be slow on a big result. Running query 2 times could be better, but you will need some logic to determine what are the source tables, 1, 1+2, or only 2.

Your choice. Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.