Because of the need to connect to Oracle so from two times development and page style personally feel phpmydatagrid is better to get started. This article begins with a MySQL-based approach, and briefly introduces two development for Oracle connectivity (based on Sqlrelay).
1. Creating a test database and tables Copy CodeThe code is as follows:
Create database ' Guru ';
Use ' Guru ';
CREATE TABLE ' Employees ' (
' ID ' int (6) not NULL auto_increment,
' Name ' char (default NULL),
' LastName ' char (default NULL),
' Salary ' float default NULL,
' Age ' int (2) default NULL,
' afiliation ' date default NULL,
' Status ' int (1) Default NULL,
' Active ' tinyint (1) Default NULL,
' Workeddays ' int (2) default NULL,
' Photo ' char (+) default NULL,
PRIMARY KEY (' id ')
)
INSERT INTO ' employees '
(' id ', ' name ', ' LastName ', ' salary ', ' age ', ' afiliation ', ' status ', ' active ', ' workeddays ', ' photo ')
VALUES (1, ' Ana ', ' Trujillo ', 2000,45, ' 2005-05-13 ', 1,1,10, ' 1.jpg ');
INSERT INTO ' employees '
(' id ', ' name ', ' LastName ', ' salary ', ' age ', ' afiliation ', ' status ', ' active ', ' workeddays ', ' photo ')
VALUES (2, ' Jennifer ', ' Aniston ', 3500,23, ' 2004-10-22 ', 1,0,0, ' 2.jpg ');
INSERT INTO ' employees '
(' id ', ' name ', ' LastName ', ' salary ', ' age ', ' afiliation ', ' status ', ' active ', ' workeddays ', ' photo ')
VALUES (3, ' Michael ', ' Norman ', 1200,19, ' 2007-01-10 ', 1,1,5, ' 3.jpg ');
INSERT INTO ' employees '
(' id ', ' name ', ' LastName ', ' salary ', ' age ', ' afiliation ', ' status ', ' active ', ' workeddays ', ' photo ')
VALUES (4, ' Vanessa ', ' Black ', 6500,31, ' 2000-11-05 ', 1,1,30, ' 4.jpg ');
INSERT INTO ' employees '
(' id ', ' name ', ' LastName ', ' salary ', ' age ', ' afiliation ', ' status ', ' active ', ' workeddays ', ' photo ')
VALUES (5, ' Michael ', ' Strauss ', 3200,45, ' 2006-10-21 ', 2,0,22, ' 5.jpg ');
INSERT INTO ' employees '
(' id ', ' name ', ' LastName ', ' salary ', ' age ', ' afiliation ', ' status ', ' active ', ' workeddays ', ' photo ')
VALUES (6, ' William ', ' Brown ', 2300,21, ' 2001-03-10 ', 3,1,10, ' 6.jpg ');
INSERT INTO ' employees '
(' id ', ' name ', ' LastName ', ' salary ', ' age ', ' afiliation ', ' status ', ' active ', ' workeddays ', ' photo ')
VALUES (7, ' Lucca ', ' Normany ', 2800,36, ' 2006-10-02 ', 3,1,20, ' 7.jpg ');
2. Introduction to PHP Programs Phpmydatagrid mainly through the phpmydatagrid.class.php,dgscripts.js to achieve, in total add up to 100kB, is a small software. For these two files are not much to say, interested students can "pack away" back to slowly product. This paper mainly introduces the use method of the software, i.e. instance datagrid_for_mysql.php. First look at the page:
Program Explanation:
Copy CodeThe code is as follows:
Include ("phpmydatagrid.class.php");
$objGrid = new DataGrid;
$objGrid->closetags (TRUE);
$objGrid->friendlyhtml ();
$objGrid->methodform ("get");
Connecting to a database
$objGrid->conectadb ("127.0.0.1", "root", "root", "Guru");//Encrypt string
$objGrid->salt ("myc0defor5tr0ng3r-pro3ection");
$objGrid->language ("en");
The last column shows the function keys, left-to-right features "new key", "Edit Key", "Delete key", "Browse key".
$objGrid->buttons (true,true,true,true);
The form name that is generated when the value is modified
$objGrid->form (' employee ', true);
Column names can be retrieved
$objGrid->searchby ("Name,lastname");
Tables that need to be read
$objGrid->tabla ("Employees");
Index values for modifying data
$objGrid->keyfield ("id");
Page display number of rows
$objGrid->datarows (20);
Default sort Mode
$objGrid->orderby ("name", "ASC");
Display column settings, related settings can refer to phpmydatagrid.class.php
$objGrid->formatcolumn ("id", "ID Employee", 5, 5, 1, "" "," Center "," Integer ");
$objGrid->formatcolumn ("name", "name", "0", "Max" and "left");
$objGrid->formatcolumn ("LastName", "Last Name", "0", "Max", "left");
$objGrid->formatcolumn ("Age", "age", 5, 5, 0, "a", "right");//Custom date format
$objGrid->formatcolumn ("Afiliation", "Afiliation Date", ten, 0, "+", "center", "date:dmy:/");//edit can be customized as Mode$objGrid->formatcolumn ("status", "status", 5, 5, 0, "$", "left", "select:1_single:2_married:3_divorced");Editing can be customized asMode$objGrid->formatcolumn ("active", "active", 2, 2, 0, "+", "center", "Check:No:Yes");//Custom Currency display form$objGrid->formatcolumn ("salary", "salary", ten, 0, "n", "right", "money:€");//data is displayed in a column chart$objGrid->formatcolumn ("Workeddays", "Work Days", 5, 2, 0, "n", "right", "chart:percent:val:31");$objGrid->checkable ();$objGrid->setheader ();$objGrid->ajax (' silent ');Echo ' Phpdatagrid ';Generate DataGrid$objGrid->grid ();Echo '';//Close database connection$objGrid->desconectar ();?> 3. Profile based on OracleThe main reading for Oracle is to modify the function in phpmydatagrid.class.php to Oracle, this is through Sqlrelay (refer to http://sqlrelay.sourceforge.net/ ), you can also use PHP's OCI8 module (which is somewhat less efficient), and then save as phporadatagrid.class.php to be called in other programs (datagrid_for_oracle.php). All of the above-mentioned programs can be found in the compact package.Hope to be useful to everyone!4. SOURCE program DownloadHttp://www.bkjia.com/PHPjc/320387.htmlWww.bkjia.comTrueHttp://www.bkjia.com/PHPjc/320387.htmlTecharticleBecause of the need to connect to Oracle so from two times development and page style personally feel phpmydatagrid is better to get started. This article first introduces the use of MySQL-based methods, and then briefly introduce ...
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.