source: schedule/Transaction/update.php@ 16740

Last change on this file since 16740 was 16740, checked in by tanio, 11 years ago
File size: 2.4 KB
Line 
1<?php
2include '../include/factdb.php';
3
4
5
6 $Time =$_GET['Time'];
7 $SelectedSource = $_GET['Source'];
8 $Date = $_GET['Date'];
9
10 $SelectedMeasure = $_GET['measure'];
11$TimeEX = explode("-",$Date);
12
13$TimeEX2 = "day=".$TimeEX[0]."&month=".$TimeEX[1]."&year=".$TimeEX[2];
14 $limtex = count(explode(",",$SelectedSource));
15$insertdate = $TimeEX[2]."-".$TimeEX[1]."-".$TimeEx[0];
16$value = $_GET['Data'];
17$date = $_GET['Date'];
18//$date = new DateTime($_GET['Date']);
19$n_value = explode(",",$value);
20echo "<br />";
21//echo $date->format('Y-m-d H:i:s');
22//fdgdfgdf
23 $Times = explode(",",$Time);
24$select = explode(",",$SelectedSource);
25$measure = explode(",",$SelectedMeasure);
26echo "<br />";
27$temp = "";
28$insert_count = 0;
29
30
31
32 $days = Date('Y-m-d',strtotime($date));
33
34 $fetch = mysql_query("SELECT * FROM schedule") or die(mysql_error());
35
36 while($rows = mysql_fetch_array($fetch)){
37 $timestamp=strtotime($rows['fLastUpdate']);
38 $timestamp2 = date('Y-m-d',$timestamp);
39 $date_time = date('H:i',$timestamp);
40 //$time_new = $date_time->format('H:i:s')
41 if($days == $timestamp2){
42
43 $delete = mysql_query("DELETE FROM `schedule` WHERE `fLastUpdate`='{$rows['fLastUpdate']}'");
44
45 }
46 }
47
48
49
50
51
52
53
54for($i=0;$i<=$limtex-1;$i++){
55$select = explode(",",$SelectedSource);
56 $n1 = $n_value[$i];
57
58 $selectf = $select[$i];
59 //////Time////
60 //$Timef = $Time[$i];
61
62 //////// for measurement /////////
63
64 $measuref = $measure[$i];
65
66 //////// Date parsing into format////////
67 $dateTime=new DateTime($date." ".$Times[$i]);
68 $parsed_date = $dateTime->format('Y-m-d H:i:s');
69 $new = 0;
70
71 $select = mysql_query("SELECT * FROM schedule WHERE fLastUpdate = '$parsed_date'");
72 if($select){
73 while($row = mysql_fetch_array($select)){
74
75
76 $new = $row['fMeasurementID'] + 1 ;
77
78
79
80 }
81 }else{
82
83 $new = 0;
84
85 }
86
87 $insert = mysql_query("INSERT IGNORE INTO schedule values('','$parsed_date','$parsed_date','$new','','$n1','$selectf','$measuref')") or die(mysql_error());
88
89}
90 if($insert){
91
92 ?>
93 <script type="text/javascript">
94
95 alert("Sucessfully save");
96 window.location = '../index.php?days=<?php echo $date; ?>';
97 </script>
98 <?php
99
100 }
101
102?>
Note: See TracBrowser for help on using the repository browser.