Because of the need to connect to Oracle, the personal feeling of Phpmydatagrid is still relatively good from two development and page styles.
1. Create Test database and table
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 ', ' Afiliat
Ion ', ' status ', ' active ', ' workeddays ', ' photo ') VALUES (1, ' Ana ', ' Trujillo ', 2000,45, ' 2005-05-13 ', 1,1,10, ' 1.jpg '); INSERT INTO ' employees ' (' IDs ', ' 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 ' (' IDs ', ' 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 ' (' IDs ', ' 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 ' (' IDs ', ' 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 ' (' IDs ', ' 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 ' (' IDs ', ' 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 Program
Phpmydatagrid mainly through the phpmydatagrid.class.php,dgscripts.js to achieve, a total of less than 100kB, but also a small software. For these two documents is not much to say, interested students can "pack away" go back slowly product. This paper mainly introduces the use method of the software, i.e. instance datagrid_for_mysql.php. First look at the page diagram:
Program Explanation:
<?php include ("phpmydatagrid.class.php");
$objGrid = new DataGrid;
$objGrid->closetags (TRUE);
$objGrid->friendlyhtml ();
$objGrid->methodform ("get"); Connect the 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, from left to right function for "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);
The column name $objGrid->searchby ("Name,lastname") can be retrieved;
The table to be read $objGrid->tabla ("Employees");
The index value is used to modify the data $objGrid->keyfield ("id");
Pagination shows the number of rows $objGrid->datarows (20);
The default Sort method $objGrid->orderby ("name", "ASC"); Display column settings, related settings can refer to phpmydatagrid.class.php $objGrid->formatcolumn ("id", "ID Employee", 5, 5, 1, "X", "Center", "integer
");
$objGrid->formatcolumn ("name", "name", "0", "M", "left");
$objGrid->formatcolumn ("LastName", "Last Name", "0", "M", "left"); $objGrid->formatcolumN ("Age", "age", 5, 5, 0, "M", "right");//Custom date format $objGrid->formatcolumn ("Afiliation", "Afiliation date", 10, 10, 0, " , "center", "date:dmy:/");//edit can be customized to <Select> mode $objGrid->formatcolumn ("status", "status", 5, 5, 0, "60"),
"Left", "select:1_single:2_married:3_divorced"); Editing can be customized for <CheckBox> mode $objGrid->formatcolumn ("active", "active", 2, 2, 0, "M", "center", "Check:No:Yes"); /Custom Currency display $objGrid->formatcolumn ("salary", "salary", ten, 0, "n", "right", "money:€");//To display the data as a histogram $objGrid->
Formatcolumn ("Workeddays", "Work Days", 5, 2, 0, "M", "right", "chart:percent:val:31");
$objGrid->checkable ();
$objGrid->setheader ();
$objGrid->ajax (' silent '); Echo '
3. Oracle Introduction
For Oracle reading is mainly to the phpmydatagrid.class.php of the function of MySQL connection to Oracle, this is through the Sqlrelay Oracle connection, of course, you can also use the OCI8 module with PHP (some low efficiency), modified to save as PHP Oradatagrid.class.php can be invoked in other programs (datagrid_for_oracle.php).
The above is to teach you how PHP directly modify the table content DataGrid function of the entire process, as well as the understanding of the database, I hope this article for everyone's learning help.