-
Notifications
You must be signed in to change notification settings - Fork 13
/
Trasanctions_rollback_commit.php
135 lines (107 loc) · 4.64 KB
/
Trasanctions_rollback_commit.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
// trans.php
function begin(){
mysql_query("BEGIN");
}
function commit(){
mysql_query("COMMIT");
}
function rollback(){
mysql_query("ROLLBACK");
}
$in_sql = "SELECT * FROM transactions WHERE payeeid = $id";
$ru_sql = mysqli_query($con, $in_sql);
$rows = mysqli_fetch_array($ru_sql);
// $accno = $rows['payeeid'];
// $ins_sql = "SELECT * FROM transactions WHERE receiveid = '$accno'";
// $run_sql = mysqli_query($con, $ins_sql);
while($rows = mysqli_fetch_array($ru_sql)){
echo '
<tbody>
<tr>
<td>'.$rows['transactionid'].'</td>
<td>'.$rows['paymentdate'].'</td>
<td>'.$rows['payeeid'].'</td>
<td>'.$rows['receiveid'].'</td>
<td>'.$rows['amount'].'</td>
<td>'.$rows['paymentstate'].'</td>
</tr>
</tbody>
';
}
?>
</table>
<div class="col-12 col-sm-6 col-md-4 col-lg-3">
<i class="icon-purse"></i>
<a href="customer.php"> <span>Dash Board</span></a>
</div>
</section></article></div>
</div>
</div>
</div>
</div>
</section>
<!-- ##### Elements Area End ##### -->
<!-- ##### Newsletter Area Start ###### -->
<section class="newsletter-area section-padding-100 bg-img jarallax" style="background-image: url(img/bg-img/6.jpg);">
<div class="container">
<div class="row justify-content-center">
<div class="col-12 col-sm-10 col-lg-8">
<div class="nl-content text-center">
<h2>Subscribe to our newsletter</h2>
<form action="#" method="post">
<input type="email" name="nl-email" id="nlemail" placeholder="Your e-mail">
<button type="submit">Subscribe</button>
</form>
<!-- <p>Curabitur elit turpis, maximus quis ullamcorper sed, maximus eu neque. Cras ultrices erat nec auctor blandit.</p> -->
</div>
</div>
</div>
</div>
</section>
<!-- ##### Newsletter Area End ###### -->
<!-- ##### Footer Area Start ##### -->
<footer class="footer-area section-padding-100-0">
<div class="container">
<div class="row">
<!-- Single Footer Widget -->
<div class="col-12 col-sm-6 col-lg-3">
<div class="single-footer-widget mb-100">
<h5 class="widget-title">About Us</h5>
<!-- Nav -->
<nav>
<ul>
<li><a href="index.php">Homepage</a></li>
<li><a href="about.html">About Us</a></li>
<li><a href="services.html">Services & Offers</a></li>
<!-- <li><a href="#">Portfolio Presentation</a></li> -->
<li><a href="post.html">The News</a></li>
</ul>
</nav>
</div>
</div>
<!-- Single Footer Widget -->
<!-- <div class="col-12 col-sm-6 col-lg-3">
<div class="single-footer-widget mb-100">
<h5 class="widget-title">Solutions</h5>
<nav>
<ul>
<li><a href="#">Our Loans</a></li>
<li><a href="#">Trading & Commerce</a></li>
<li><a href="#">Banking & Private Equity</a></li>
<li><a href="#">Industrial & Factory</a></li>
<li><a href="#">Financial Solutions</a></li>
</ul>
</nav>
</div>
</div> -->
$result = mysql_query($query);
if(!$result){
rollback(); // transaction rolls back
echo "transaction rolled back";
exit;
}else{
commit(); // transaction is committed
echo "Database transaction was successful";
}
?>