Because you need to connect to Oracle, from the secondary development and page style, I personally think phpMyDataGrid is better to use. This article first introduces how to use MySQL, and then briefly introduces the secondary development of Oracle connection (based on sqlrelay.
1. Create a test database and table
Copy codeThe Code is as follows:
Create database 'guru ';
USE 'guru ';
Create table 'employees '(
'Id' int (6) not null auto_increment,
'Name' char (20) default NULL,
'Lastname' char (20) default NULL,
'Salary 'float default NULL,
'Age' int (2) default NULL,
'A' date default NULL,
'Status' int (1) default NULL,
'Active' tinyint (1) default NULL,
'Workeddays' int (2) default NULL,
'Photo' char (30) default NULL,
Primary key ('id ')
)
Insert into 'ployees'
('Id', 'name', 'lastname', 'salary ', 'age', 'afiliation', 'status', 'active', 'workeddays ', 'photo ')
Values (1, 'ana ', 'trujillo', 2005, 45, '2017-05-13', 10, '1.jpg ');
Insert into 'ployees'
('Id', 'name', 'lastname', 'salary ', 'age', 'afiliation', 'status', 'active', 'workeddays ', 'photo ')
Values (2, 'jennifer ', 'aniston', 2004, 23, '2017-10-22', 0, '2.jpg ');
Insert into 'ployees'
('Id', 'name', 'lastname', 'salary ', 'age', 'afiliation', 'status', 'active', 'workeddays ', 'photo ')
Values (3, 'Michael ', 'Norman', 2007, '1970-01-10 ', 5, '3.jpg ');
Insert into 'ployees'
('Id', 'name', 'lastname', 'salary ', 'age', 'afiliation', 'status', 'active', 'workeddays ', 'photo ')
Values (4, 'wasa', 'black', 2000, 31, '2017-11-05 ', 30, '4.jpg ');
Insert into 'ployees'
('Id', 'name', 'lastname', 'salary ', 'age', 'afiliation', 'status', 'active', 'workeddays ', 'photo ')
Values (5, 'Michael ', 'strauss', 2006, 45, '2017-10-21 ', 22, '5.jpg ');
Insert into 'ployees'
('Id', 'name', 'lastname', 'salary ', 'age', 'afiliation', 'status', 'active', 'workeddays ', 'photo ')
Values (6, 'william', 'Brown ', 2001, 21, '2017-03-10', 10, '6.jpg ');
Insert into 'ployees'
('Id', 'name', 'lastname', 'salary ', 'age', 'afiliation', 'status', 'active', 'workeddays ', 'photo ')
Values (7, 'lucca ', 'northeast', 2006, 36, '2017-10-02', 20, '7.jpg ');
2. PHP program Introduction
PhpMyDataGrid is mainly implemented through phpmydatagrid. class. php and dgscripts. js. The total size is less than kb, and it is a small software. I will not talk about these two files much. If you are interested, you can "pack and take it" back to the product. This section describes how to use the software, that is, the instance datagrid_for_mysql.php. Let's take a look at the page:
Program description:
Copy codeThe Code is as follows:
<? Php
Include ("phpmydatagrid. class. php ");
$ ObjGrid = new datagrid;
$ ObjGrid-> closeTags (true );
$ ObjGrid-> friendlyHTML ();
$ ObjGrid-> methodForm ("get ");
// Connect to the database
$ ObjGrid-> conectadb ("127.0.0.1", "root", "root", "guru"); // encrypted string
$ ObjGrid-> salt ("Myc0defor5tr0ng3r-Pro3EctiOn ");
$ ObjGrid-> language ("en ");
// The function key displayed in the last column. The options include "add key", "Edit key", "delete key", and "Browse key ".
$ ObjGrid-> buttons (true, true );
// Modify the Form name generated by the numeric value
$ ObjGrid-> form ('Employee', true );
// Searchable column name
$ ObjGrid-> searchby ("name, lastname ");
// The table to be read
$ ObjGrid-> tabla ("employees ");
// The index value is used to modify data.
$ ObjGrid-> keyfield ("id ");
// Number of lines displayed by PAGE
$ ObjGrid-> datarows (20 );
// Default sorting method
$ ObjGrid-> orderby ("name", "ASC ");
// Display column settings. For more information, see phpmydatagrid. class. php.
$ ObjGrid-> FormatColumn ("id", "ID Employee", 5, 5, 1, "50", "center", "integer ");
$ ObjGrid-> FormatColumn ("name", "Name", 30, 30, 0, "150", "left ");
$ ObjGrid-> FormatColumn ("lastname", "Last name", 30, 30, 0, "150", "left ");
$ ObjGrid-> FormatColumn ("age", "Age", 5, 5, 0, "50", "right"); // custom Date Format
$ ObjGrid-> FormatColumn ("afiliation", "Afiliation Date", 10, 10, 0, "100", "center", "date: dmy :/"); // The <Select> mode can be customized during editing.
$ ObjGrid-> FormatColumn ("status", "Status", 5, 5, 0, "60", "left", "select: distinct single: 2_Married: 3_Divorced ");
// The <CheckBox> mode can be customized during editing.
$ ObjGrid-> FormatColumn ("active", "Active", 2, 2, 0, "50", "center", "check: No: Yes "); // display the custom currency
$ ObjGrid-> FormatColumn ("salary", "Salary", 10, 10, 0, "90", "right", "money: € "); // display data in a column chart
$ ObjGrid-> FormatColumn ("workeddays", "Work days", 5, 2, 0, "50", "right", "chart: percent: val: 31 ");
$ ObjGrid-> checkable ();
$ ObjGrid-> setHeader ();
$ ObjGrid-> ajax ('silent ');
Echo '<Head> <title> PHPDataGrid </title> <Body> <div align = "center"> <br/> ';
// Generate the DataGrid
$ ObjGrid-> grid ();
Echo '</div> </body> $ ObjGrid-> desconectar ();
?>
3. Oracle-based introduction
For Oracle reading, phpmydatagrid is mainly used. class. in php and MySQL connection function modified to Oracle, this article is through sqlrelay (can refer to the http://sqlrelay.sourceforge.net/) for Oracle connection, of course, you can also use the built-in PHP OCI8 module (low efficiency) and save it as phporadatagrid. class. php can be called in other programs (datagrid_for_oracle.php. All the programs involved above can be found in the compressed package.
Hope to be useful to everyone!
4. source program download