


This article mainly introduces the student implemented based on the Codeigniterframework The dynamic publishing function of the information system site provides a detailed analysis of the database sql statements, MVC functions and implementation techniques of each module related to the dynamic site. Friends in need can refer to the following
This article describes an example based on Codeigniter The dynamic publishing function of the student information system site implemented by the framework is shared with everyone for your reference. The details are as follows:
Since it is a dynamic site, there must be a database table. Without further ado, let’s take a look at the database. Table:
CREATE TABLE IF NOT EXISTS `student`( //主键id `id` int(11) NOT NULL AUTO_INCREMENT, //学生姓名 `s_name` varchar(64) NOT NULL, //学生家长的姓名 `p_name` varchar(64) NOT NULL, //学生的家庭住址 `address` varchar(100) NOT NULL, //所在城市 `city` varchar(30) NOT NULL, //所在国家 `state` varchar(30) NOT NULL, //所在地区的邮政编码 `zip` varchar(20) NOT NULL, //电话 `phone` varchar(15) NOT NULL, //邮件 `email` varchar(20) NOT NULL, //主键设置 PRIMARY KEY(`id`) )ENGINE=INNODB DEFAULT CHARSET=UTF8 AUTO_INCREMENT=1;
*Note: There are two places I need to explain here:
1. "IF NOT EXISTS": If the data is added in front when creating the table "IF NOT EXISTS" means that even if the table already exists, it will be executed successfully;
2. "ENGINE=INNODB": This is the engine setting of the database, commonly used mysql database Engines include ISAM, MYISAM, HEAP, etc.;
After creating the data table, let’s take a look at the database connection. Open the .\application\config\database.php file and set the database variable parameters in it. Set the basic URL in the .\application\config\config.php file. For me, the basic URL is: localhost/codeigniter/
Let’s take a look at the mvc ideaArchitecture Design
First open the .application\controllers\ file directory and create a student.phpcontroller:
student.php
In Let's first 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 it and look at the following code:
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:
<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Strict//EN' 'http://www.w3.org/TR/html4/strict.dtd'> <html> <head> <meta http-equiv='Content-Type' content='text/html; charset=utf-8'> <title><?php echo $title; ?></title> </head> <body> <h1><?php echo $headline; ?></h1> <?php $this->load->view($include)?> </body> </html>
Among them:
this−>load−>view(include);
contains another view file student_index.php file
student_index.php:
<p>Congratulations. Your initial setup is complete!</p>
Joint output:
welcome to the classroom Mangement System Congratulations. Your initial setup is complete!
CURD of data
C Controller
Let’s first look at the process of adding data, add an add() in the student controller Method
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
<html> <head> <title><?php echo $title;?></title> </head> <body> <h1><?php echo $headline ?></h1> <?php $this->load->view($include)?> </body> </html>
student_add.php
<?php echo form_open('student/create'); $field_name=array('s_name','p_name','address','city','state','zip','phone','email'); foreach($field_name as $value){ echo "<p>".$value.":" echo form_input(array('name'=>$value)); echo "</p>" } form_submit('','Add'); form_close(); ?>
update_student.php
<?php echo $updatetable; ?>
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 the detailed content of Detailed explanation of the case of dynamic publishing function code for student information system site based on Codeigniter framework. For more information, please follow other related articles on the PHP Chinese website!

如何在CodeIgniter中实现自定义中间件引言:在现代的Web开发中,中间件在应用程序中起着至关重要的作用。它们可以用来执行在请求到达控制器之前或之后执行一些共享的处理逻辑。CodeIgniter作为一个流行的PHP框架,也支持中间件的使用。本文将介绍如何在CodeIgniter中实现自定义中间件,并提供一个简单的代码示例。中间件概述:中间件是一种在请求

CodeIgniter中间件:加速应用程序的响应速度和页面渲染概述:随着网络应用程序的复杂性和交互性不断增长,开发人员需要使用更加高效和可扩展的解决方案来提高应用程序的性能和响应速度。CodeIgniter(CI)是一种基于PHP的轻量级框架,提供了许多有用的功能,其中之一就是中间件。中间件是在请求到达控制器之前或之后执行的一系列任务。这篇文章将介绍如何使用

在CodeIgniter框架中使用数据库查询构建器(QueryBuilder)的方法引言:CodeIgniter是一个轻量级的PHP框架,它提供了许多功能强大的工具和库,方便开发人员进行Web应用程序开发。其中一个令人印象深刻的功能是数据库查询构建器(QueryBuilder),它提供了一种简洁而强大的方法来构建和执行数据库查询语句。本文将介绍如何在Co

随着Web应用程序的不断发展,更加快速和高效地开发应用程序变得非常重要。并且,随着RESTfulAPI在Web应用程序中的广泛应用,对于开发人员来说,必须理解如何创建和实现RESTfulAPI。在本文中,我们将讨论如何使用CodeIgniter框架实现MVC模式和RESTfulAPI。MVC模式简介MVC(Model-Vie

CodeIgniter是一个轻量级的PHP框架,采用MVC架构,支持快速开发和简化常见任务。CodeIgniter5是该框架的最新版本,提供了许多新的特性和改进。本文将介绍如何使用CodeIgniter5框架来构建一个简单的Web应用程序。步骤1:安装CodeIgniter5下载和安装CodeIgniter5非常简单,只需要遵循以下步骤:下载最新版本

现今互联网时代,一款深受用户喜爱的网站必须具备简洁明了的前端界面和功能强大的后台管理系统,而PHP框架CodeIgniter则是一款能够让开发者快速搭建后台管理系统的优秀框架。CodeIgniter拥有轻量级、高效率、易扩展等特点,本文将针对初学者,详细说明如何通过该框架快速搭建一个后台管理系统。一、安装配置安装PHPCodeIgniter是一个基于PHP的

随着移动互联网的发展,即时通信变得越来越重要,越来越普及。对于很多企业而言,实时聊天更像是一种通信服务,提供便捷的沟通方式,可以快速有效地解决业务方面的问题。基于此,本文将介绍如何使用PHP框架CodeIgniter开发一个实时聊天应用。了解CodeIgniter框架CodeIgniter是一个轻量级的PHP框架,提供了一系列的简便的工具和库,帮助开发者快速

近年来,Web开发技术的进步和全球互联网应用的不断扩大,使得PHP技术应用面越来越广泛。作为一种快速开发的技术,其生态系统也在不断发展壮大。其中,CodeIgniter作为PHP开发领域中著名的框架之一,备受众多开发者的欢迎。本篇文章将介绍CodeIgniter框架的相关知识,以此为初学者提供一个入门的指引。一、什么是CodeIgniter框架?CodeIg


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
