-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopytask.php
67 lines (54 loc) · 1.98 KB
/
copytask.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
$id=$_REQUEST['taskid'];
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("tasks") or die(mysql_error());
mysql_query("set character_set_client=utf8");
mysql_query("set character_set_connection=utf8");
mysql_query("set collation_connection=utf8");
mysql_query("set character_set_results=utf8");
$sql="CREATE TEMPORARY TABLE tmp SELECT * FROM tasks WHERE taskid = ".$id.";";
print $sql;
$data = mysql_query($sql)
or die(mysql_error());
$sql= "UPDATE tmp SET completed=0,kodikos='' WHERE taskid =".$id.";";
print $sql;
$data = mysql_query($sql)
or die(mysql_error());
$sql= "UPDATE tmp SET taskid=(SELECT MAX(taskid)+1 FROM tasks) WHERE taskid =".$id.";";
print $sql;
$data = mysql_query($sql)
or die(mysql_error());
$sql="INSERT INTO tasks SELECT * FROM tmp;";
print $sql;
$data = mysql_query($sql)
or die(mysql_error());
$newrecord=mysql_insert_id();
$sql="DROP TEMPORARY TABLE tmp";
$data = mysql_query($sql)
or die(mysql_error());
print $sql;
$sql="CREATE TEMPORARY TABLE tmp SELECT * FROM actions WHERE taskid = ".$id." order by actionid;";
print $sql;
$data = mysql_query($sql)
or die(mysql_error());
$sql="UPDATE tmp SET taskid=".$newrecord." WHERE taskid =".$id." order by actionid;";
print $sql;
$data = mysql_query($sql)
or die(mysql_error());
//$sql="UPDATE tmp SET actionid=(SELECT MAX(actionid)+1 FROM actions) WHERE taskid =".$id.";";
//$sql="UPDATE tmp SET actionid=(SELECT MAX(actionid)+1 FROM actions);";
$sql="UPDATE tmp SET actionid=null";
print $sql;
$data = mysql_query($sql)
or die(mysql_error());
$sql="INSERT INTO actions SELECT * FROM tmp";
print $sql;
$data = mysql_query($sql)
or die(mysql_error());
print $sql;
$sql="DROP TEMPORARY TABLE tmp";
$data = mysql_query($sql)
or die(mysql_error());
print $sql;
header('Location:edittasks.php?taskid='.$newrecord);
?>