I Love PHPMaker

... because it gets even more powerful and flexible!!

  • About
  • Terms and Conditions
  • Membership Options
  • Sitemap
  • Downloads
    • PHPMaker Extensions Download
    • PHPMaker Projects Download
    • PHP Report Maker Extensions Download
I Love PHPMaker » Tips and Trick » A Case Study: Adding Prev Next Navigation Links in the Master/Details Page of Websites that Generated by PHPMaker 9.1.0
How to Change the Values of Constants On The Fly in Websites that Generated by PHPMaker
How to Remove Menu in Websites that Generated by PHPMaker 9.1.0

January 31, 2013

A Case Study: Adding Prev Next Navigation Links in the Master/Details Page of Websites that Generated by PHPMaker 9.1.0

Have you ever wanted to add the Previous and Next navigation links in the Master/Details pages of web applications that generated by PHPMaker? As we have already known, PHPMaker can generate the Master/Detail pages powerfully only in a few seconds. Unfortunately, it has not provided the navigation links as well as the pagination links in the List pages in order to go or browse to the next or previous records/page quickly.

In this article, I will show you how you can add the navigation links in a Master/Detail page easily and quickly. We will add the code from Server Events of PHPMaker. In other words, you don't have to customize the generated scripts for this. This navigation links is very useful for your users, so they don't have to go back to its Master page each time they want to go to the next or previous Master/Detail records.

In this example, I am using the following tables for the Master/Details relationships:
- products (master) -> orders (detail)
- orders (master) -> order_details (detail)
- products (master) -> components (detail)

As a result, I also just created a video for you. Please note that this following video below is related to this article that I wrote a few days ago. In other words, make sure you have already had the related files and follow all steps in that article before implementing the solution in this article.

Updated on February 10, 2013: This customization has been implemented in PHPMaker version 9.2.0, it matches to each other, and as a result, it works properly.

[hidepost]

  1. Double click your orders.pmp file, and it should call PHPMaker to run it.
  2. Now let's add the navigation links in the orderslist.php page. To do this, click on orders table in the database (left) pane, and then click on Code (Server Events, Client Scripts and Custom Templates) tab. Expand this location: Server Events -> Table-Specific -> List Page -> Page_DataRendering, and then insert the following code into the Page_DataRendering function:

        if (@$_GET["showmaster"]=="products" && isset($_GET["Id"])) {
          $maxID = ew_ExecuteScalar("SELECT MAX(Id) FROM products");
          $minID = ew_ExecuteScalar("SELECT MIN(Id) FROM products");
          $curID = intval($_GET["Id"]);
          if ($curID < $maxID) {
            $nextID = $curID + 1;
          } else {
            $nextID = $minID;      
          }        
          if ($curID > $minID) {
            $prevID = intval($_GET["Id"]) - 1;                        
          } else {
            $prevID = $maxID;        
          }      
          $header = "<a href='orderslist.php?showmaster=products&Id=".$prevID."' title='Product ".$prevID."'>Prev</a>";      
          $header .= "&nbsp;|&nbsp;<a href='orderslist.php?showmaster=products&Id=".$nextID."' title='Product ".$nextID."'>Next</a>";
        }
    
  3. Next step, let's add again the navigation links in the order_detailslist.php page. To do this, click on order_details table in the database (left) pane, and then click on Code (Server Events, Client Scripts and Custom Templates) tab. Expand this location: Server Events -> Table-Specific -> List Page -> Page_DataRendering, and then insert the following code into the Page_DataRendering function:

        if (@$_GET["showmaster"]=="orders" && isset($_GET["Id"])) {
          $maxID = ew_ExecuteScalar("SELECT MAX(Id) FROM orders");
          $minID = ew_ExecuteScalar("SELECT MIN(Id) FROM orders");
          $curID = intval($_GET["Id"]);
          if ($curID < $maxID) {
            $nextID = $curID + 1;
          } else {
            $nextID = $minID;      
          }        
          if ($curID > $minID) {
            $prevID = intval($_GET["Id"]) - 1;                        
          } else {
            $prevID = $maxID;        
          }      
          $header = "<a href='order_detailslist.php?showmaster=orders&Id=".$prevID."' title='Order ".$prevID."'>Prev</a>";      
          $header .= "&nbsp;|&nbsp;<a href='order_detailslist.php?showmaster=orders&Id=".$nextID."' title='Order ".$nextID."'>Next</a>";
        }
    
  4. Next step, let's add again the navigation links in the componentslist.php page. To do this, click on components table in the database (left) pane, and then click on Code (Server Events, Client Scripts and Custom Templates) tab. Expand this location: Server Events -> Table-Specific -> List Page -> Page_DataRendering, and then insert the following code into the Page_DataRendering function:

        if (@$_GET["showmaster"]=="products" && isset($_GET["Id"])) {
          $maxID = ew_ExecuteScalar("SELECT MAX(Id) FROM products");
          $minID = ew_ExecuteScalar("SELECT MIN(Id) FROM products");
          $curID = intval($_GET["Id"]);
          if ($curID < $maxID) {
            $nextID = $curID + 1;
          } else {
            $nextID = $minID;      
          }        
          if ($curID > $minID) {
            $prevID = intval($_GET["Id"]) - 1;                        
          } else {
            $prevID = $maxID;        
          }      
          $header = "<a href='componentslist.php?showmaster=products&Id=".$prevID."' title='Product ".$prevID."'>Prev</a>";      
          $header .= "&nbsp;|&nbsp;<a href='componentslist.php?showmaster=products&Id=".$nextID."' title='Product ".$nextID."'>Next</a>";
        } 
    
  5. Finally, re-generate your script files using PHPMaker as always.

[/hidepost]

Article by Masino Sinaga / Tips and Trick / detail table, master table, master-detail, navigation links, next, PHPMaker 9.1.0, PHPMaker 9.2.0, previous, Server Events Leave a Comment

How to Change the Values of Constants On The Fly in Websites that Generated by PHPMaker
How to Remove Menu in Websites that Generated by PHPMaker 9.1.0

Leave a Reply Cancel reply

You must be logged in to post a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Recent Posts

  • A New PHPMaker 2025 Project File Is Released
  • PHPMaker 2025 Demo Project File Is Released
  • Masino Extensions for PHPMaker 2025 Is Released!
  • A New PHPMaker 2024 Project File Is Released
  • PHPMaker 2024 Demo Project File Is Released
  • Masino Extensions for PHPMaker 2024 Is Released!
  • PHPMakerProjects.com, For Those Who Need PHPMaker Project Sample
  • A New PHPMaker 2023 Project File Is Released
  • PHPMaker 2023 Demo Project File Is Released
  • Masino Extensions for PHPMaker 2023 Is Released!

Search

Recent Comments

  • Masino Sinaga on Masino Extensions for PHPMaker 2024 Is Released!
  • Masino Sinaga on A New PHPMaker 2024 Project File Is Released
  • Masino Sinaga on PHPMaker 2023 Demo Project File Is Released
  • Edward Babatunde on PHPMaker 2023 Demo Project File Is Released
  • Edward Babatunde on Masino Extensions for PHPMaker 2024 Is Released!

Demo Website

  • Demo of I Love PHPMaker 2025 (MasinoExtensions).
  • Stock Inventory Management for PHPMaker 2025.

Another Demo

The following template are not available in this site (must be purchased separately)

  • PHPMaker v2018 Horizontal Vertical Template.
  • PHPMaker v2017 Horizontal Vertical Template.

Demo Explanation

Stock Inventory Management is the good project for your reference, since it uses the real example in the real world. Many useful features you can use from this project, such as how to add the Thousand and Decimal separator character, and also how to calculate multiple row in Grid-Add when End-Users are entering data into the Grid-Add mode.

Categories

  • Customize Template (103)
  • General (4)
  • PHP Report Maker (17)
  • PHP Report Maker Extensions (2)
  • PHPMaker Extensions (84)
  • PHPMaker Projects (7)
  • Tips and Trick (72)

Articles based on version

  • PHPMaker 2025
  • PHPMaker 2024
  • PHPMaker 2023
  • PHPMaker 2022
  • PHPMaker 2021
  • PHPMaker 2020
  • PHPMaker 2019
  • PHPMaker 2018
  • PHPMaker 2017.0.7
  • PHPMaker 12.0.7
  • PHPMaker 11.0.6
  • PHPMaker 10.0.5
  • PHPMaker 9.2.0
  • PHPMaker 8.0.3
  • PHP Report Maker 12

(c) I Love PHPMaker 2010 - 2025 by Masino Sinaga | WordPress | Log in | Back to top