source: trunk/www/db_po/get_timestamp.php@ 12379

Last change on this file since 12379 was 11503, checked in by Daniela Dorner, 13 years ago
added (script to get timestamp from database)
  • Property svn:executable set to *
File size: 1.5 KB
Line 
1<?php
2{
3 ini_set("display_errors", "On");
4 ini_set("mysql.trace_mode", "On");
5
6 if (empty($_GET["fStatusDate"]))
7 $_GET["fStatusDate"]="";
8 if (empty($_GET["fDirection"]))
9 {
10 echo "Please give the direction.<br>";
11 return;
12 }
13
14 include("db.php");
15 $db_id = mysql_pconnect($host, $user, $pw);
16 if ($db_id==FALSE)
17 {
18 printf("mysql_connect returned the following error: %s\n", mysql_error());
19 die("");
20 }
21 mysql_select_db($db);
22
23 if (strcmp($_GET["fDirection"], "next")==0)
24 $query0 ="SELECT Max(fCounter)+1 FROM History WHERE fValidFrom like '".$_GET["fStatusDate"]."%'";
25 if (strcmp($_GET["fDirection"], "prev")==0)
26 $query0 ="SELECT Max(fCounter)-1 FROM History WHERE fValidFrom like '".$_GET["fStatusDate"]."%'";
27 $result0=mysql_query($query0, $db_id);
28 $row0 = mysql_fetch_row($result0);
29 $counter1=$row0[0];
30 mysql_free_result($result0);
31
32 $query1 = "SELECT Max(fCounter) FROM History";
33 $result1=mysql_query($query1, $db_id);
34 $row1 = mysql_fetch_row($result1);
35 $counter2=$row1[0];
36 mysql_free_result($result1);
37
38 if ($counter1>$counter2)
39 $counter=$counter2;
40 else
41 $counter=$counter1;
42
43 $query1 = "SELECT fValidFrom FROM History WHERE fCounter=".$counter;
44 $result1=mysql_query($query1, $db_id);
45 $row1 = mysql_fetch_row($result1);
46 $validfrom=$row1[0];
47 mysql_free_result($result1);
48 echo $validfrom;
49
50 mysql_close($db_id);
51
52 ini_set("display_errors", "Off");
53 ini_set("mysql.trace_mode", "Off");
54}
55?>
Note: See TracBrowser for help on using the repository browser.