source: trunk/www/db_po/get_date.php@ 11599

Last change on this file since 11599 was 11599, checked in by Daniela Dorner, 13 years ago
added various new features (min, max, user, show/hide of columns, ...) and changed layout
  • Property svn:executable set to *
File size: 3.4 KB
Line 
1<?php
2{
3 ini_set("display_errors", "On");
4 ini_set("mysql.trace_mode", "On");
5
6 if (empty($_GET["fDateValue"]))
7 {
8 echo "Please give the date value.<br>";
9 return;
10 }
11 if (empty($_GET["fDateName"]))
12 {
13 echo "Please give the date name.<br>";
14 return;
15 }
16 if (empty($_GET["fIdx"]))
17 {
18 echo "Please give the idx.<br>";
19 return;
20 }
21 if (empty($_GET["fDateValuePrev"]))
22 $_GET["fDateValuePrev"]="";
23 if (empty($_GET["fStatusDate"]))
24 $_GET["fStatusDate"]="";
25
26 include("db.php");
27 $db_id = mysql_pconnect($host, $user, $pw);
28 if ($db_id==FALSE)
29 {
30 printf("mysql_connect returned the following error: %s\n", mysql_error());
31 die("");
32 }
33 mysql_select_db($db);
34
35 if (strcmp("year",$_GET["fDateName"])==0)
36 {
37 $identifier1="";
38 $identifier2="Y";
39 $newdatename="month";
40 if (strcmp($_GET["fDateValue"],"empty")==0)
41 $_GET["fDateValue"]="all";
42 if (strcmp($_GET["fDateValuePrev"],"empty")==0)
43 $_GET["fDateValuePrev"]="all";
44 }
45 if (strcmp("month",$_GET["fDateName"])==0)
46 {
47 $identifier1="%Y";
48 $identifier2="m";
49 $newdatename="day";
50 }
51 if (strcmp("day",$_GET["fDateName"])==0)
52 {
53 $identifier1="%Y-%m";
54 $identifier2="d";
55 $newdatename="hour";
56 }
57 if (strcmp("hour",$_GET["fDateName"])==0)
58 {
59 $identifier1="%Y-%m-%d";
60 $identifier2="H";
61 $newdatename="min";
62 }
63 if (strcmp("min",$_GET["fDateName"])==0)
64 {
65 $identifier1="%Y-%m-%d %H";
66 $identifier2="i";
67 $newdatename="sec";
68 }
69 if (strcmp("sec",$_GET["fDateName"])==0)
70 {
71 $identifier1="%Y-%m-%d %H:%i";
72 $identifier2="s";
73 $newdatename="";
74 }
75
76 if (strcmp($_GET["fDateValuePrev"],"empty")!=0)
77 {
78 $query0 ="SELECT ";
79 $query0.=" Date_Format(fValidFrom, '%". $identifier2."') as valid ";
80 $query0.=" FROM History ";
81 if (empty($identifier1))
82 $query0.=" WHERE NOT fValidFrom='0000-00-00 00:00:00' ";
83 else
84 $query0.=" WHERE Date_Format(fValidFrom, '". $identifier1."')='".$_GET["fStatusDate"]."'";
85 //$query0.=" WHERE Date_Format(fValidFrom, '%". $identifier1."')=".$_GET["fDateValuePrev"];
86 $query0.=" GROUP BY valid";
87 $result0=mysql_query($query0, $db_id);
88 }
89 //echo $query0;
90
91 if (empty($newdatename))
92 printf("<select id='%s%d'>\n", $_GET["fDateName"], $_GET["fIdx"]);
93 else
94 printf("<select id='%s%d' onchange=\"get_dates('%s', this.value, this.value, %d, 'yes')\">\n",
95 $_GET["fDateName"], $_GET["fIdx"], $newdatename, $_GET["fIdx"]);
96 if (strcmp($_GET["fDateValue"],"empty")!=0)
97 printf("<option value='empty'>%s</option>\n", $_GET["fDateName"]);
98 else
99 printf("<option value='empty'>-</option>\n");
100 if (strcmp($_GET["fDateValuePreV"],"empty")!=0)
101 {
102 while ($row0 = mysql_fetch_row($result0))
103 {
104 if (strcmp($row0[0],$_GET["fDateValue"])==0)
105 printf("<option value='%s' selected>%s </option>\n", $row0[0], $row0[0]);
106 else
107 printf("<option value='%s'>%s </option>\n", $row0[0], $row0[0]);
108 }
109 mysql_free_result($result0);
110 }
111 printf("</select>\n");
112
113 mysql_close($db_id);
114
115 ini_set("display_errors", "Off");
116 ini_set("mysql.trace_mode", "Off");
117}
118?>
Note: See TracBrowser for help on using the repository browser.