source: tags/Mars-V2.1.1/datacenter/db/printtable.php

Last change on this file was 8249, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 2.3 KB
Line 
1<?php
2{
3 function PrintForm($_GET)
4 {
5 if (empty($_GET["fTable"]))
6 {
7 printf("ERROR - No table selected.\n");
8 return;
9 }
10 }
11
12 function PrintPage($html, $host, $user, $pw, $db, $limits, $rms)
13 {
14 if (empty($_GET["fTable"]))
15 {
16 printf("ERROR - No table selected.\n");
17 return;
18
19 }
20
21 $db_id = mysql_connect($host, $user, $pw);
22 if ($db_id==FALSE)
23 {
24 printf("mysql_connect returned the following error: %s\n", mysql_error());
25 die("");
26 }
27 mysql_select_db($db);
28
29 $fromtable=$_GET["fTable"];
30 $query0 = "SELECT * FROM " . $fromtable;
31 if (!empty($_GET["fSortBy"]))
32 {
33 $val=substr($_GET["fSortBy"], 0, -1);
34 $query0 .= " ORDER BY " . GetTable($fromtable,$val) . " ";
35 if (substr($_GET["fSortBy"], -1)=="-")
36 $query0 .= "DESC";
37 }
38
39
40 $result0 = mysql_query($query0, $db_id);
41
42 if ($result0)
43 {
44 if ($html=="1")
45 {
46 $alias = array
47 (
48 );
49 $rightalign = array
50 (
51 );
52 PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);
53 }
54 else
55 PrintText($result0);
56
57 mysql_free_result($result0);
58 }
59 mysql_close($db_id);
60
61 PrintSubmittedQuery($query0, $html, $db, "old");
62 }
63
64 include ("include.php");
65 include ("db.php");
66 include ("magicdefs.php");
67
68 ini_set("display_errors", "On");
69 ini_set("mysql.trace_mode", "On");
70
71 if (!empty($_GET["fSendTxt"]))
72 {
73 header("Content-type: application/octet");
74 header("Content-Disposition: attachment; filename=query-result.txt");
75
76 PrintPage("0", $host, $user, $pw, $db, "", "");
77 }
78 else
79 {
80 echo (file_get_contents("index-header.html"));
81
82 $environment = sizeof($_GET);
83
84 PrintForm($_GET);
85
86 if ($environment==0)
87 printf("No query submitted yet.<BR>");
88 else
89 PrintPage("1", $host, $user, $pw, $db, "", "");
90
91 echo (file_get_contents("index-footer.html"));
92 }
93
94 ini_set("display_errors", "Off");
95 ini_set("mysql.trace_mode", "Off");
96}
97?>
Note: See TracBrowser for help on using the repository browser.