PCCS MySQLDatabase Admin Tool version 1.3.4


/ -> mysqldb_info.php

1   <?php
2   //////////////////////////////////////////////////////////////////////////////////////
3   // coder: cthorn
4   // mysqldb_info.php
5   //
6  /************************************************************************
7  PCCS MySQLDatabase Admin Tool
8  Copyright (C) 1999 Chauncey Thorn
9 
10  This program is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License
12  as published by the Free Software Foundation; either version 2
13  of the License, or (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA , USA.
23  **************************************************************************/
24 
25  // updated 10-23-2000
26  // -- moving to a single file for global include files
27    
28  require('mysqldb_app_includes.php');
29     
30     common_header($_title);
31 
32  pageTop("PCCS MySQLAdmin Tool: DATABASE INFO","600");
33 
34      $mysql_version = mysqlquery("$db_name","SELECT Version() as version");
35     $display_mysql_version = mysql_result($mysql_version,0,"version");
36     print "<p>";
37     if ($argv[0] == ""):
38     // Displays a blank page
39     // We always want to pass a action to this script
40     //
41      $menu = "MYSQL DATABASE TABLE INFO";
42          else:
43      $menu = "MYSQL DATABASE TABLE INFO";
44          endif;
45    
46     //print "<H3 align=center><FONT COLOR=blue>$_title : $menu </FONT></H3>";
47     // heading();
48     print "<P> <CENTER><FONT SIZE=+2 >";
49     print "</FONT></CENTER>";
50     print "<P>";
51 
52     $qry = "SHOW PROCESSLIST";
53     $res = mysql($db_name,$qry);
54          $ps = mysql_numrows($res);
55     print "<CENTER>";
56     print "<P>";
57     print "[ ";
58     print "<A HREF=./ CLASS=noul>MAIN</A>&nbsp;";
59     print "| <A HREF=installscript/mysqldb_installscript.php CLASS=noul>$str_installscriptlink</A>&nbsp;";
60 
61     print "| <A HREF=$MySQLManual CLASS=noul
62     onMouseOver=\"window.status='$str_readmysqldoc'; return
63  true;\" onMouseOut=\"window.status=' '; return true;\" TARGET=_new>$str_readmysqldoc</A>&nbsp;";
64     print " ]";
65     print "</CENTER>";
66     print "<p>";
67   
68 
69  ?>
70 
71   <H2 ALIGN=center> <?echo "The $dbname database has the following tables:" ?></H2>
72 
73 
74  <?php
75  // updated 10-22-2000
76  // moved away for SQL query, using PHP function
77  // Complete rewrite move function in global.vars.php
78  // Used to display tables within a database
79  // URL: action=tables&dbname=databasename
80    
81  if($action =="tables"):
82 
83          getTables();
84 
85  endif;
86 
87 
88  // Used by the PHP Framework
89  // Displays column and Created submit button for table selected
90  // URL: action=columns&dbname=databasename&tblname=tablename
91  //
92  // updated 10-22-2000
93  // changed to begin_genapp from columns
94  // URL: action=begin_genapp&dbname=databasename&tblname=tablename
95 
96  if($action =="begin_genapp"):
97 
98  ?>
99 
100   <H2 ALIGN=center> <?echo "The $tblname table has the following fields:" ?></H2>
101 
102        <? $result = mysqlquery("mysql","SHOW COLUMNS from $tblname FROM $dbname ");?>
103     <? $num = mysql_numrows($result);
104        $c1 = "#CCCCCC";
105        $c2 = "#CCCCCC";?>
106        <CENTER>
107 
108        <TABLE BORDER=0 CELLSPACING=2 CELLPADDING=0>
109              <TR>
110              <TH ALIGN=left>Field</TH>
111           <TH ALIGN=left>Type</TH>
112           <TH ALIGN=left>Null</TH>
113           <TH ALIGN=left>Key</TH>
114           <TH ALIGN=left>Default</TH>
115           <TH ALIGN=left>Extra</TH>
116              </TR>
117           <? for ($i =0 ;$i < $num; $i++):
118              if ($c == $c1):
119                 $c = $c2;
120              else:
121                 $c = $c1;
122              endif;?>
123              <TR BGCOLOR=<? echo $c ?>>
124           <TD ALIGN=left><?echo mysql_result($result,$i,"Field")?></TD>
125           <TD ALIGN=left><?echo mysql_result($result,$i,"Type")?></TD>
126           <TD ALIGN=left><?echo mysql_result($result,$i,"Null")?></TD>
127           <TD ALIGN=left><?echo mysql_result($result,$i,"Key")?></TD>
128           <TD ALIGN=left><?echo mysql_result($result,$i,"Default")?></TD>
129           <TD ALIGN=left><?echo mysql_result($result,$i,"Extra")?></TD>
130 
131              </TR>
132           <? endfor ?>
133        </TABLE>
134         <p>
135           <FORM ACTION="genapp/mysqldb_createapp.php" METHOD=post>
136           <INPUT TYPE=hidden NAME=dbname VALUE="<?echo $dbname ?>">
137           <INPUT TYPE=hidden NAME=tablename VALUE="<?echo $tblname ?>">
138           <INPUT TYPE=submit VALUE="Generate PHP Framework on this table">
139           </FORM>
140           <p>
141        <? print "<P>"; print "<A HREF=javascript:history.back()>BACK</A>"; ?>
142        </CENTER>
143        
144  <? endif; ?>
145   
146  <?
147 
148 
149  if($action =="tbldetails"):
150  // field descriptions for table
151  // URL: action=tbldetails&dbname=databasename&tblname=tablename
152  //
153 
154  $f = mysql_list_fields($dbname,$tblname);
155 
156  print "<center>";
157  print "Field Descriptions for Table : &nbsp;&nbsp;".$tblname;
158  print "<table>";
159  print "<tr><th>NAME</th><th>FLAGS</th><th>LENGHT</th><th>TYPE</th></tr>";
160  for($fld=0; $fld<mysql_num_fields($f); $fld++){
161          $fields[$fld]["name"] = mysql_field_name($f,$fld);
162          $fields[$fld]["flags"] = mysql_field_flags($f,$fld);
163          $fields[$fld]["len"] = mysql_field_len($f,$fld);
164          $fields[$fld]["type"] = mysql_field_type($f,$fld);
165          print "<tr><td>" .$fields[$fld]["name"]."</td><td>".$fields[$fld]["type"]."</td><td>".$fields[$fld]["len"]."</td><td>".$fields[$fld]["flags"]."</td></tr>";
166  }
167  print "</table>";
168  print "</center>";
169  print "<P><A HREF=$PHP_SELF?action=tables&dbname=$dbname>BACK</A>";
170 
171 
172  endif;
173 
174 
175  pageBottom();
176  // footer();
177 
178  ?>


Generated: Sat Jan 27 15:40:36 2001 Generated by PHPXref 0.1.2
PCCS-Linux.COM ::ource Advocate Articles catalogue
2000 2002