Detailed description of the code case for implementing the student information system site dynamic release function based on the Codeigniter framework

Source: Internet
Author: User
This article mainly introduces the student information system site dynamic release function based on Codeigniter framework. it analyzes in detail the Database SQL statements related to dynamic sites, the functions and implementation skills of various MVC modules, the student information system site dynamic publishing function based on Codeigniter # css/css-rwd-frameworks.html "target =" _ blank "> framework is introduced, this article analyzes in detail the Database SQL statements related to dynamic sites, functions and implementation skills of various MVC modules. if you need them, refer

This document describes how to dynamically publish student information system sites based on the Codeigniter framework. We will share this with you for your reference. The details are as follows:

Since it is a dynamic site, there must be a database table, which is not nonsense here. let's take a look at the database table:

Create table if not exists 'student '(// primary key id 'id' int (11) not null AUTO_INCREMENT, // student name's _ name' varchar (64) not null, // the parents' name 'P _ name' varchar (64) not null, // The student's home address 'address' varchar (100) not null, // The city 'city' varchar (30) not null, // The country 'state' varchar (30) not null, // The zip code 'Zip' varchar (20) not null for the region, // The phone number 'phone' varchar (15) not null, // The email 'email 'varchar (20) not null, // set the primary key to primary key ('id') ENGINE = innodb default charset = UTF8 AUTO_INCREMENT = 1;

* Note: I have two points to explain:

1. "if not exists": IF "if not exists" is added before the table is created, the operation is successful even IF the table already EXISTS;

2. "ENGINE = INNODB": this is the database ENGINE settings. commonly used mysql database engines include ISAM, MYISAM, and HEAP;

After creating the data table, let's take a look at the database connection. Open. \ application \ config \ database. php file, including set Database variable parameters, in. \ application \ config. set the basic URL in the PHP file. for my basic url: localhost/codeigniter/

Let's take a look at the design of the mvc ideological architecture.

First open the. application \ controllers \ file directory, and create a student. php controller in it:

Student. php

Here we will test it through the student controller and print out helloworld. remember that the access path is localhost/codeigniter/index. php/student/index.

class student extends CI_Controller{    //student controller construct    public function construct(){     parent::construct();    }    //index test function    public function index(){     echo "helloworld";    }}

It output: helloworld

Let's change the code below:

class student extends CI_Controller{    //student controller    public function construct(){      parent::construct();    }    //define a array,name is arraydata, it have three parameters    protected $arraydata=array(      'title'=>'Classroom:Home page',      'headline'=>'welcome to the classroom Mangement System',      'include'=>'student_index'    );    //index function    public function index(){      $this->load->view('template',$this->arraydata);    }}

This code requires a View, template. php

Template. php:

 <?php echo $title; ?>  
   
 load->view($include)?>

Where:

this−>load−>view(include);

It contains another view file, studen_index.php.

Student_index.php:

Congratulations. Your initial setup is complete!

Combined output:

welcome to the classroom Mangement SystemCongratulations. Your initial setup is complete!

Data CURD

C controller

Let's take a look at the data addition process and add an add () method to the student controller.

class student extends CI_Controller{    //student controller    public function construct(){      parent::construct();    }    //new add function    public function add(){      $this->load->helper('form');      //display information for the view      $data['title']='Classroom:Add Page';      $data['headline']='Add data';      $data['include']='student_add';      //upload view      $this->load->view('template',$data);    }    //create function    public function create(){      $this->load->helper('url');      $this->load->model('MStudent','',TRUE);      $this->MStudent->addData($_POST);      redirect('student/add','reflesh');    }    //update function    public function update(){      //upload codeigniter library      $this->load->library('table');      $this->load->model('MStudent','',TRUE);      $student_query=$this->MStudent->updateData();      $update_table=$this->table->generate($student_query);      //display information for the view      $data['title']='Classroom:Update Page';      $data['headline']='Update Page';      $data['include']='update_student';      $data['updatetable']=$update_table;      $this->load->view('template',$data);    }    //index function    public function index(){      $data['title']='Classroom:Home page';      $data['headline']='welcome to classroom Mangement System';      $data['include']='student_index';      $this->load->view('template',$this->arraydata);    }}

V view

Template. php

      <?php echo $title;?>        
     
 load->view($include)?>  

Student_add.php

 ".$value.":"    echo form_input(array('name'=>$value));    echo "

" } form_submit('','Add'); form_close();?>

Update_student.php

 

M model

class MStudent extends CI_Model{  public function addData($data){    $this->db->insert('student',$data);  }  public function updateData(){    $this->db->get('student');  }}

The above is a detailed description of the code case for implementing the function code of the student information system website dynamic release based on the Codeigniter framework. For more information, see other related articles in the first PHP community!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.