473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Pagination in php

250 100+
I want to put pagination in my search result. my code is working but got an error saying:Non-static method Pager::factory() should not be called statically in...
This is my code.

Expand|Select|Wrap|Line Numbers
  1. require_once 'Pager/Pager.php';
  2. $sqlQuery = "select * from vehicles";
  3. $result = mysql_query($sqlQuery);
  4. $totalRows = mysql_num_rows($result);
  5.  
  6. $pager_options = array(
  7. 'mode'       => 'Sliding',
  8. 'perPage'    => 20,
  9. 'delta'      => 4,
  10. 'totalItems' => $totalRows,
  11. );
  12.  
  13. $pager =Pager::factory($pager_options);
  14.  
  15. echo $pager->links;
  16. list($from, $to) = $pager->getOffsetByPageId();
  17.  
  18. $from = $from - 1;
  19.  
  20. /* The number of rows to get per query */
  21. $perPage = $pager_options['perPage'];
  22.  
  23. $result = mysql_query("SELECT * FROM vehicles LIMIT $from , $perPage");
  24.  
  25.  
  26. echo "<table width=100% align=center>";
  27.                         echo "&nbsp;&nbsp;<tr height=20 bgcolor=#C0C0C0><td align=center>Vehicle Id</td><td align=center>Vehicle Make</td><td align=center>Vehicle Model</td><td>SELECT</td></tr>";
  28.  
  29.                         while($row = mysql_fetch_array($result))
  30.                         {
  31.                             foreach( $row AS $key => $val ){
  32.                             $$key = stripslashes( $val );
  33.                             }
  34.  
  35.                             echo "<tr class=normalText>";
  36.                              echo "<td> $vehicleId</td>";
  37.                             echo "<td> $vehicleMake</td>";
  38.                             echo "<td> $vehicleModel</td>";
  39.  
  40.                             echo  "<td><a href='javascript:void(0);' onclick=\"LookupVehicle('$vehicleType','$vehicleMake'); return false;\">Select</a></td>";
  41.                                     echo "</tr>";
  42.                             }
  43.                             echo "</table>";
  44.  
This is the error line.
Expand|Select|Wrap|Line Numbers
  1. $pager =Pager::factory($pager_options);
Please help me..
Sep 9 '11 #1
3 2166
Dormilich
8,658 Expert Mod 8TB
the error is right, if you didn’t declare the method static in the class definition, you should call it like an object method (i.e. $obj->method()). whether you should do this or declare the method static depends on the method implementation, though.
Sep 10 '11 #2
ghjk
250 100+
Thanx Dormilich. I solved it. But Now I'm having another problem. When I click page no 2; web banner and all other page options not displayed and only disply the pagination part. How can I solve this problem. I have searched many days and found this solution. Please help me. Now I'm really stuck. Please help me to solve this or please tell me about another working pagination tutorial..
Sep 12 '11 #3
Dormilich
8,658 Expert Mod 8TB
When I click page no 2; web banner and all other page options not displayed and only disply the pagination part
sounds like the links used are incorrect.

please tell me about another working pagination tutorial.
I don’t know any. I already have my own pagination system. Google certainly knows some more.
Sep 12 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Sharif T. Karim | last post by:
Anyone know of a up-to-date tutorial for pagination where I can have it like: Prev 1 2 3 4 Next Thanks. -- Sharif T. Karim ....you don't know wrath yet...
1
by: Faree | last post by:
I am workign on a news portal which needs paginaiton as usual.but all the code i got depends on the number of records that will come from database :( .it is working well too. But i need...
1
by: Kruq | last post by:
Is it possible to use pagination with DataList? Can't find it.. :( Kruq
2
by: Chris H | last post by:
I am having a problem with pagination, basically the problem is happening in the "PREV / NUMBERS / NEXT" links, it appears as if the reason is becasue the increment and decrement operators aren't...
11
by: ste | last post by:
Hi there, Further to my recent posts where I've received excellent help from Rik and Jerry, I've ended up with an image gallery on my website that displays images in a table, 3 images per row. ...
1
by: shalini jain | last post by:
Hi, I want to know how can we do pagination using XSL. There are number of tutorials available on pagination using PHP but nothing with XSL. i am really stuck with my code. Below is the code that...
16
by: gnawz | last post by:
I have a pagination function I am using in a file called functions.php as below<? //Pagination functions function getPagingQuery($sql, $itemPerPage = 10) { if (isset($_GET) && (int)$_GET > 0) ...
4
by: ArizonaJohn | last post by:
Hello, The code below works great. The user enters a name into an HTML form, the code looks up a table with that name, and then that table is displayed. I am trying to use pagination with it,...
2
by: kkshansid | last post by:
this is my search page on which i am getting two parameters from previous page but the problem is that as soon as i click any other next pages my sql query fails as it doesnt get these two parameters...
1
by: rienh | last post by:
I'am using Adam's pagination script from: http://www.developphp.com/view_lesson.php?v=289 And I adjusted the code just a little, so it fitted my needs. Now I bumb into a problem, and I can't figure...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.