Using PHP to develop HR system (5)



This section describes how to split pages and usejqueryandajaxLocal refresh


From our page, the menu on the left is unchanged, and the content area on the right changes according to different menus, so we wonder whether we can only focus on

For local refresh on the right, you can use ajaxTechnology to complete.


1 split home page


We divide the page structure into four areas: 1, top of pageTopRegion;2, left side of pageMenuRegion;3, middle area of the page;4, bottom of pagefooterRegion;

According to this division, we put main_The list is divided into top, menu and footer, and the page head is also separated. See the following steps for details:

1) in viewCreate under directorycontainer.phpreplacemain_List.php file


defined(‘BASEPATH’) OR exit(‘No direct script access allowed’);



load->view(‘templates/header’); ?>

load->view(‘templates/top’); ?>

load->view(‘templates/menu’); ?>

load->view(‘main’); ?>        


load->view(‘templates/footer’); ?>

Through the transformation, our homepage code looks very simple, including several files:

i)header.php(view->Templates) to store pagesheadBlock code:


Software Service Manager System


<!–        –>

<!–        –>







ii)top.php(view->Templates) to store pagestopContents of the area:

‘); ?>”>

Metro Lab





  • Jhon Doe

  •         Swing

  • My information
  • My settings
  • Sign out

    iii)menu.php(view->Templates) to store pagesmenuBlock code:


    iV)footer.php(view->Templates) to store pagesfooterBlock code:


    <!–        –>



    V)main.php(viewDirectory) to store the content area code of the main page of the page:


    Total number of employees


    Number of people to be recruited


    Number of employees in this month


    Number of employees leaving this month


    Number of people to be recruited this month


    Salary and benefits of the year


    Salary and benefits of this month



    2)At present, our engineering structure is as follows


    2. Modify the controllers – > main.php file


    defined(‘BASEPATH’) OR exit(‘No direct script access allowed’);


    class Main extends CI_Controller {


    public function __construct(){





    public function index()





    3 ajaxApplication

    In order to achieve local refresh, we introduce Ajax to realize it.

    1) at footerAdd the following to the. PHP file


    Among them, sub1 corresponds to the “employee information” menu in menu.php.

    3 running test

    The operation homepage is as follows:

    Click “employee information” menu, the page is as follows



    In this paper, we first split the home page to make the module more independent and the page code clearer. At the same time, we use ajax.Technology, to achieve the local refresh of the page;


    ====================================The End==========================


















    Recommended Today

    Query SAP multiple database table sizes

    Query SAP multiple database table sizes Item code db02 Here are two approaches, In the first graphical interface, the results of the query data table are displayed in MB, and only one table can be queried at a time. SPACE—Segments—Detailed Analysis—Detailed Analysis  In the pop-up window segment / object, enter the name of the […]