473,836 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ


90 New Member
its me again

on my displaying page, i want to limit the records to display on it. and display the link to go next pages to view the balance.

is it possible?

thanks in advance.

Sep 19 '08 #1
3 1122
190 New Member
ya its possible, try limit in ur query according to ur page index.

see this

http://www.plus2net.co m/php_tutorial/php_paging.php
Sep 19 '08 #2
90 New Member
hi all

i got it.....

Expand|Select|Wrap|Line Numbers
  1. <?php
  3. $rowsPerPage = 3;
  5. $pageNum = 1;
  6. if(isset($_GET['page']))
  7. {
  8.     $pageNum = $_GET['page'];
  9. }
  12. $offset = ($pageNum - 1) * $rowsPerPage;
  14. $query = " SELECT * FROM user " .
  15.          " LIMIT $offset, $rowsPerPage";
  16. $result = mysql_query($query) or die('Error, query failed');
  18. while($row = mysql_fetch_array($result))
  19. {
  20.  // reading database
  21. }
  23. echo "<table align='center' border='0'>";
  24. //printing
  25. echo "</table>";
  28. $query   = "SELECT COUNT(refno) AS numrows FROM myfriends WHERE refno='$refno'";
  29. $result  = mysql_query($query) or die('Error, query failed');
  30. $row     = mysql_fetch_array($result, MYSQL_ASSOC);
  31. $numrows = $row['numrows'];
  33. $maxPage = ceil($numrows/$rowsPerPage);
  36. $self = $_SERVER['PHP_SELF'];
  37. $nav  = '';
  39. for($page = 1; $page <= $maxPage; $page++)
  40. {
  41.    if ($page == $pageNum)
  42.    {
  43.       $nav .= " $page "; // no need to create a link to current page
  44.    }
  45.    else
  46.    {
  47.       $nav .= " <a href=\"$self?page=$page\">$page</a> ";
  48.    } 
  49. }
  51. if ($pageNum > 1)
  52. {
  53.    $page  = $pageNum - 1;
  54.    $prev  = " <a href=\"$self?page=$page\">[Prev]</a> ";
  56.    $first = " <a href=\"$self?page=1\">[First Page]</a> ";
  57. else
  58. {
  59.    $prev  = '&nbsp;'; 
  60.    $first = '&nbsp;'; 
  61. }
  63. if ($pageNum < $maxPage)
  64. {
  65.    $page = $pageNum + 1;
  66.    $next = " <a href=\"$self?page=$page\">[Next]</a> ";
  68.    $last = " <a href=\"$self?page=$maxPage\">[Last Page]</a> ";
  69. else
  70. {
  71.    $next = '&nbsp;'; 
  72.    $last = '&nbsp;'; 
  73. }
  75. echo "<br><br>";
  76. echo $first . $prev . $nav . $next . $last;
  78. ?>

Sep 19 '08 #3
90 New Member
ya its possible, try limit in ur query according to ur page index.

see this

http://www.plus2net.co m/php_tutorial/php_paging.php
thanks maheswaran

Sep 19 '08 #4

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

Similar topics

by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update not the whole page, but a portion of the page. Strangely enough the URL below http://beta.asp.net/QUICKSTARTV20/aspnet/doc/ctrlref/data/gridview.aspx (VB GridView Paging and Sorting Callbacks example)
by: RelaxoRy | last post by:
sqlConnection1.Open(); myReader = sqlCommand1.ExecuteReader(); DataGrid1.DataSource = myReader; DataGrid1.DataBind(); myReader.Close(); sqlConnection1.Close(); The Datagrid populates fine. I'm styling it on the HTML page. I configure the DataGrid for paging through the property builder fine. I AllowCustomePaging=true;. The page loads fine but it only shows "1"
by: Guoqi Zheng | last post by:
Sir, The default paging of datagrid is somehow use too much resource, so I am using Stored procedure for the paging. You can find my Stored procedure at the end of this message. It works fine to do paging like this, however, I have found it difficult to do paging and sorting at the same time. For example, in my case, my boss asked me to do sorting on EmailAddress,
by: Shawn | last post by:
Hi. I already have a datagrid where I'm using paging. I have a stored procedure that fills a temp table with 200-500 rows and then sends back 10 records at the time. When I go to page 2 the SP fills the temp table again and returns rows 10-19. The temp table is dropped after each call to the SP, so it has to be created and filled every time the user changes page in the datagrid. My question is this: Would it be more efficient to...
by: asad | last post by:
Hello friends, i am designing a ASP.NET page where i want to use custom paging bcoz data is too heavy so pls tell me how can i use custom paging in ASP.NET Thanks
by: farhad13841384 | last post by:
Hi , I Hope You fine. I have some problem with this code for paging in asp.net this bottom code work correctly without any error but when I try to place separate code in .VB file then error is begin and occured .I want to separate this code and compiling .vb code using VBC.exe later .(bin/paging.dll) when do it like me so you retrive only < Previous Page Next Page > in your web browser and you don't retrive list Of data in your web browser....
by: anonieko | last post by:
This approach I found very efficient and FAST when compared to the rowcount, or Subquery Approaches. This is before the advent of a ranking function from DB such as ROW_NUMBER() in SQL Server 2005 and the likes of it. So This one works with SQL2000 What do you think?
by: rn5a | last post by:
In a shopping cart app, a ASPX page retrieves the order details & personal details of a user from a MS-Access database table depending upon the username of the user. The order details of a particular order (like ProductID, Name, Description, Quantity etc.) are displayed in one DataGrid where as the personal details of the buyer corresponding to this order (like Name, E-Mail, Shipping & Billing Address etc.) are displayed in another...
by: Ronald S. Cook | last post by:
I was told that if calling lots of records from the database (let's say 100,000), that the GridView's paging feature would automatically "handle" everything. But the 100,000 records are still coming to the client, right? I mean, the paging feature isn't somehow making calls to the database for 25 records at a time or anything like that is it? I remember in the past having to write nasty stored procedures that took in
by: Donald Adams | last post by:
Hi, I will have both web and win clients and would like to page my data. I could not find out how the datagrid control does it's paging though I did find some sample code that says they do it this way, but I can't see these methods as public. BookmarksDataSetTableAdapters.BookmarksTableAdapter bookTA = new BookmarksDataSetTableAdapters.BookmarksTableAdapter(); BookmarkList1.DataSource = bookTA.GetAllBookmarksWrtUser(
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.