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
|
<?php include 'config.php';
// Check if the user is logged in
if ((!isSet($_SESSION['loginname'])) || ($loggin <> '1')) { header("Location: login.php"); exit; }
$id = (int)$_GET["id"];
$sql2 = "select * from rolling_text where id = ?";
if (!($sth2 = $dbh->prepare($sql2))) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth2->errorInfo())); }
if (!$sth2->execute(array($id))) { throw new Exception('[' . $sth2->errorCode() . ']: ' . print_r($sth2->errorInfo())); } $row = $sth2->fetch(PDO::FETCH_ASSOC);
$sort = $row{"sort"};
// Delete db $sql2 = "update rolling_text set deleted = ?, lastupdate=?, lastupby=? WHERE id=?";
if (!($sth2 = $dbh->prepare($sql2))) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth2->errorInfo())); }
if (!$sth2->execute(array("1", $nowdate, $_SESSION["cmsloginid"], $id))) { throw new Exception('[' . $sth2->errorCode() . ']: ' . print_r($sth2->errorInfo())); }
//update sorting $sql2 = "update rolling_text set sort = sort-1 where sort > ?";
if (!($sth2 = $dbh->prepare($sql2))) { throw new Exception('[' . $sth->errorCode() . ']: ' . print_r($sth2->errorInfo())); }
if (!$sth2->execute(array($sort))) { throw new Exception('[' . $sth2->errorCode() . ']: ' . print_r($sth2->errorInfo())); }
$dbh = null;
header("Location: rolling_text_index.php?msg=Deleted");
?>
|