1
+ <?php
2
+ use phpGrid \C_DataGrid ;
3
+
4
+ require_once ("phpGridx/conf.php " );
5
+
6
+ ?>
7
+ <!DOCTYPE html>
8
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
9
+ <head>
10
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
11
+ <title>DB Admin</title>
12
+ </head>
13
+ <body>
14
+
15
+ <style type='text/css'>
16
+ .wrapper{
17
+ width: 100%;
18
+ margin: 0 auto;
19
+ }
20
+ .header{
21
+ float: left;
22
+ width: 100%;
23
+ text-align: center;
24
+ }
25
+ .wrapright{
26
+ float: left;
27
+ width: 100%;
28
+ }
29
+ .right{
30
+ margin-left: 310px;
31
+ height: 200px;
32
+ }
33
+ .left{
34
+ float: left;
35
+ width: 300px;
36
+ margin-left: -100%;
37
+ height: 200px;
38
+ }
39
+ body {
40
+ padding: 15px;
41
+ margin: 15px;
42
+ }
43
+ </style>
44
+
45
+ <div class="wrapper">
46
+ <div class="header">
47
+ <h1>Database Table Data CRUD Admin Console</h1>
48
+ </div>
49
+ <div class="wrapright">
50
+ <div class="right">
51
+ <?php
52
+ $ schemaName = (isset ($ _GET ['TABLE_SCHEMA ' ]) && isset ($ _GET ['TABLE_SCHEMA ' ]) !== '' ) ? $ _GET ['TABLE_SCHEMA ' ] : 'sampledb ' ;
53
+ $ tableName = (isset ($ _GET ['TABLE_NAME ' ]) && isset ($ _GET ['TABLE_NAME ' ]) !== '' ) ? $ _GET ['TABLE_NAME ' ] : 'orders ' ;
54
+
55
+ //$dg = new C_DataGrid("SELECT * FROM $schemaName.$tableName");
56
+
57
+ $ dg = new C_DataGrid ("SELECT * FROM $ tableName " ,'orderNumber ' , "$ tableName " ,
58
+ array ("hostname " =>"localhost " ,
59
+ "username " =>"root " ,
60
+ "password " =>"" ,
61
+ "dbname " =>$ schemaName ,
62
+ "dbtype " =>"mysql " ,
63
+ "dbcharset " =>"utf8 " ));
64
+ $ dg ->set_caption (strtoupper ("$ schemaName. $ tableName " ));
65
+
66
+ $ dg ->enable_autowidth (true );
67
+ $ dg ->enable_edit ();
68
+ $ dg ->set_scroll (true );
69
+ $ dg ->enable_global_search (true );
70
+
71
+ // uncomment to set width to parent DIV instead
72
+ $ dg ->before_script_end .= 'setTimeout(function(){$(window).bind("resize", function() {
73
+ phpGrid_ ' . $ tableName .'.setGridWidth($(".right").width());
74
+ }).trigger("resize");}, 0) ' ;
75
+
76
+ $ dg -> display ();
77
+ ?>
78
+ </div>
79
+ </div>
80
+ <div class="left">
81
+ <?php
82
+ // schema list
83
+ $ dbs = new C_DataGrid ("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA " , "SCHEMA_NAME " , "INFORMATION_SCHEMA.SCHEMATA " );
84
+ $ dbs ->set_dimension ('300px ' );
85
+ $ dbs ->set_pagesize (999 )->set_scroll (true );
86
+
87
+ // table list
88
+ $ tbl = new C_DataGrid ("SELECT TABLE_NAME, TABLE_SCHEMA, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES " , "TABLE_NAME " , "INFORMATION_SCHEMA.TABLES " );
89
+ $ tbl ->set_col_hidden ('TABLE_SCHEMA ' );
90
+ $ tbl ->set_pagesize (999 )->set_scroll (true );
91
+ $ tbl -> set_col_dynalink ("TABLE_NAME " , "db_admin.php " , array ("TABLE_NAME " , "TABLE_SCHEMA " ), '' , "_top " );
92
+ //$tbl->set_col_title('TABLE_NAME', 'Name')->set_col_title('TABLE_ROWS', 'Count');
93
+
94
+ $ dbs ->set_subgrid ($ tbl , 'TABLE_SCHEMA ' , 'SCHEMA_NAME ' );
95
+ $ dbs ->display ();
96
+ ?>
97
+ </div>
98
+ </div>
99
+
100
+ TODO: add form only mode
101
+
102
+
103
+ </body>
104
+ </html>
0 commit comments