PCCS MySQLDatabase Admin Tool version 1.3.4


/ -> mysqldb_displayqry.php

1    <?php
2 
3  // updated 10-23-2000
4  // -- moving to a single file for global include files
5    
6  require('mysqldb_app_includes.php');
7 
8     common_header($_title);
9  ?>
10 
11      <P>
12    
13      <CENTER>
14      <TABLE BGCOLOR=#000000 CELLSPACING=0 CELLPADDING=2 ALIGN=CENTER
15       BORDER=0 VALIGN=MIDDLE ><TR><TD BGCOLOR=#000000>
16 
17      <TABLE BORDER=0 CELLSPACING=2 CELLPADDING=2 ALIGN=CENTER
18       VALIGN=CENTER BGCOLOR=#dddddd WIDTH=100%><TR><TD>
19    
20        <TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0 ALIGN=CENTER
21         VALIGN=TOP BORDER=0><TR BGCOLOR=#0022cf>
22         <TD BGCOLOR=#ffffff>
23         <CENTER><FONT FACE="Arial, Helvetica, Verdana"
24          SIZE=+1 ><B><?php heading() ?></B></FONT></CENTER>
25        </TD>
26        <TD BGCOLOR=#ffffff ALIGN=RIGHT WIDTH=32>
27        &nbsp;
28        </TD></TR></TABLE>
29      
30  <P>
31 
32  <?php
33     
34 
35  $border = "0";
36  $th_bgcolor = "#D3DCE3";
37  $bgcolor_one = "#CCCCCC";
38  $bgcolor_two = "#DDDDDD";
39  $max_rows = "1000";
40 
41  $pos = 0;
42 
43  if($action == "run_query"):
44          print "
45          <table bgcolor=\"#FFFFFF\" border=2 cellspacing=0 cellpadding=3 align=center>
46          <tr>
47                  <td bgcolor=\"#999999\">Run SQL Query on Table: [ <font
48                  color=red>$table</font> ]
49                  from database: [ <font color=red>$dbname</font> ]</td>
50          </tr>
51          <tr>
52                  <td align=center>
53                  <form method=\"post\" action=\"$PHP_SELF?action=get_results\">
54                          <textarea name=\"qry\" cols=50 rows=15>SELECT \nFROM
55                          $table \n</textarea><br>
56                          <input type=hidden name=\"table\" value=\"$table\">
57                          <input type=hidden name=\"dbname\" value=\"$dbname\">
58                          <input type=submit name=\"submit\" value=\"Submit Query\">
59 
60                          </form>
61          </tr>
62  </table>";
63          
64  endif ;
65 
66  if($action == "read_query"):
67          print "
68          <table bgcolor=\"#FFFFFF\" border=2 cellspacing=0 cellpadding=3 align=center>
69          <tr>
70                  <td bgcolor=\"#999999\">Run SQL Query on Table: [ <font
71                  color=red>$table</font> ]
72                  from database: [ <font color=red>$dbname</font> ]</td>
73          </tr>
74          <tr>
75                  <td align=center>
76                  <form method=\"post\" action=\"$PHP_SELF?action=get_results\">
77                          <textarea name=\"qry\" cols=50 rows=15>";
78                          $qryfn = "$webshare$sqldir$fn";
79                           readfile("$qryfn");
80          print"
81                          </textarea><br>
82                          <input type=submit name=\"submit\" value=\"Submit Query\">
83                          <input type=hidden name=\"table\" value=\"$table\">
84                          <input type=hidden name=\"dbname\" value=\"$dbname\">
85                          </form>
86          </tr>
87  </table>";
88          
89  endif ;
90 
91 
92  if($action == "get_results"):
93  print "<p>";
94  print "<table><tr>";
95 
96  $qry = "select * from $table";
97  $qry = addslashes($qry);
98  $result = mysqlquery("$dbname",$qry);
99         if (!$result)
100            {
101            // mysql_die();
102            }
103         else
104            {
105            $num_rows = @mysql_num_rows($result);
106            if ($num_rows < 1)
107               {
108               if (isset($zero_rows))
109                  {
110                  echo $zero_rows;
111                  }
112               else
113                  {
114                  echo "NO DATA Returned";
115                  echo "<P>";
116                  echo "<A HREF=mysqldb_info.php?action=tables&dbname=$dbname>Back
117                  to Tables</a>";
118                  }
119               }
120            else
121               {
122           if (!isset($pos))
123       {
124       $pos = 0;
125       }
126    $pos_next = $pos + $max_rows;
127    $pos_prev = $pos - $max_rows;
128 
129   if (@mysql_num_rows($dt_result)>1)
130      {
131      echo "Showing Records $pos - $pos_next (".mysql_num_rows($result)." Total )";
132      }
133          
134           while ($field = mysql_fetch_field($result))
135          {
136          if (@mysql_num_rows($result)>1)
137              {
138              $sql_sort=urlencode("select * from $table order by $field->name $order");
139              echo "<th><font color=blue>$field->name</font></th>\n";
140              }
141          else
142              {
143               echo "<th>$field->name</th>";
144 
145              }
146          $table = $field->table;
147          }
148    echo "</tr>\n";
149    $foo = 0;
150 
151    while ($row = mysql_fetch_row($result))
152          {
153          if ($foo < $pos_next && $foo >= $pos)
154             {
155             $primary_key = "";
156             $bgcolor = $bgcolor_one;
157             $foo % 2 ? 0: $bgcolor = $bgcolor_two;
158             echo "<tr bgcolor=$bgcolor>";
159             for ($i=0; $i<mysql_num_fields($result); $i++)
160                 {
161                 $primary = mysql_fetch_field($result,$i);
162                 if ($primary->numeric == 1)
163                    {
164                    echo "<td align=right>&nbsp;$row[$i]&nbsp;</td>\n";
165                    }
166                 else
167                    {
168                    echo "<td>&nbsp;".htmlspecialchars($row[$i])."&nbsp;</td>\n";
169                    }
170                 if ($primary->primary_key > 0)
171                    {
172                    $primary_key .= " $primary->name = '$row[$i]' AND";
173                    }
174                 }
175             if ($primary_key)
176                {
177                $primary_key = urlencode(ereg_replace("AND$", "", $primary_key));
178                $query = "&db=$db&table=$table";
179             
180                }
181             echo "</tr>\n";
182             }
183          $foo++;
184          }
185   echo "</table>\n";
186  echo "<P>";
187  echo " <A HREF=./mysqldb_info.php?action=tables&dbname=$dbname> Back to Tables </A>";
188          
189               }
190            }
191          
192  endif;
193  ?>
194  <P>
195  </TD>
196  </TR>
197  </TABLE>
198 
199 
200 
201  </TD></TR></TABLE>
202  </TD></TR></TABLE>
203  </CENTER>


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