· 8 years ago · Jan 25, 2018, 07:10 PM
1Suleyman owes Jacopo 100
2
3Jacopo owes Suleyman 200
4
5Suleyman owes Jacopo 0 - make the debt to Jacopo dissapear from Suleyman.php
6
7Jacopo owes Suleyman 100 - change the debt to Suleyman in Jacopo.php
8
9Suleyman owes Jacopo 100
10 Jacopo owes Suleyman 100
11
12Suleyman owes Jacopo 0
13 Jacopo owes Suleyman 0
14
15<!DOCTYPE html>
16<html lang="en">
17<head>
18 <meta charset="UTF-8">
19 <title>Sulik App</title>
20 <link rel="stylesheet" type="text/css" href="style.css">
21 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
22 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
23 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script>
24 <style type="text/css">
25 body {
26 background-image: url(1.jpg);
27 font-size:16px;
28 }
29 .wrapper{
30 width: 950px;
31 margin: 0 auto;
32 }
33 .page-header h2{
34 margin-top: 0;
35 }
36 table tr td:last-child a{
37 margin-right: 15px;
38 color:blue;
39 font-size: 20px
40 }
41 </style>
42 <script type="text/javascript">
43 $(document).ready(function(){
44 $('[data-toggle="tooltip"]').tooltip();
45 });
46 </script>
47</head>
48<body>
49 <div class="wrapper">
50 <div class="container-fluid">
51 <div class="row">
52 <div class="col-md-12">
53 <div class="page-header clearfix">
54 <h2 class="pull-left">Suleyman</h2>
55 <a href="index.php" class="btn btn-danger pull-right">Go Back</a>
56
57
58 </div>
59 <?php
60 $name = 'Suleyman';
61 $new_array = array();
62 // Include config file
63 require_once 'config.php';
64 // Create database connection
65
66
67
68
69
70 // Attempt select query execution
71 $sql = "SELECT * FROM `payments` WHERE `check_list` IN ('Suleyman' , 'Suleyman,Jacopo' , 'Everybody' , 'Suleyman,Denis', 'Suleyman,Angus' ) ";
72 if($result = mysqli_query($link, $sql)){
73 if(mysqli_num_rows($result) > 0){
74 echo "<table class='table table-bordered table-striped'>";
75 echo "<thead>";
76 echo "<tr>";
77 echo "<th>#</th>";
78 echo "<th>Who paid for it</th>";
79 echo "<th>Date of payment</th>";
80 echo "<th>Payment name</th>";
81 echo "<th>How much</th>";
82 echo "<th>My Debt</th>";
83 $total_qty = 0;
84
85
86 echo "<th>Action</th>";
87 echo "</tr>";
88 echo "</thead>";
89 echo "<tbody>";
90 while($row = mysqli_fetch_array($result)){
91 echo "<tr>";
92 echo "<td>" . $row['id'] . "</td>";
93 echo "<td>" . $row['name'] . "</td>";
94 echo "<td>" . $row['dates'] . "</td>";
95 echo "<td>" . $row['product'] . "</td>";
96 echo "<td>" . $row['amount'] . " €". "</td>";
97 if($row['name'] == 'Suleyman'){echo "<td>" . 0 . " €". "</td>";}else{
98 echo "<td>" . $row['Sul'] . " €". "</td>";};
99 if($row['name'] == 'Suleyman'){;}else{
100 $total_qty += $row['Sul'];};
101 if($row['name'] == 'Suleyman'){/*do nothing*/}else{
102 if(isset($new_array[$row['name']])){//here i checked if the array key exists like $new_array['Jacopo']
103 $new_array[$row['name']] += $row['Sul'];//if exists sum the old value with the new one
104 }else{
105 $new_array[$row['name']] = $row['Sul'];//else put it in the array as new value with new key
106 }
107 }
108
109
110
111
112
113 echo "<td>";
114 echo "<a href='image.php?id=" ."' title='Add Check' data-toggle='tooltip'><span class='glyphicon glyphicon-upload'></span></a>";
115 echo "<a href='sulupdate.php?id=". $row['id'] ."' title='Edit My Debt' data-toggle='tooltip'><span class='glyphicon glyphicon-edit'></span></a>";
116
117 echo "</td>";
118 echo "</tr>";
119 }
120 echo "</tbody>";
121 echo "</table>";
122 // Free result set
123 mysqli_free_result($result);
124 } else{
125 echo "<p class='lead'><em>No records were found.</em></p>";
126 }
127 } else{
128 echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
129 }
130
131 // Close connection
132 mysqli_close($link);
133 ?>
134 </div>
135 </div>
136 </div>
137</div>
138 <center><h3>Total Debt: <?php if (!empty($total_qty)) { echo $total_qty;} ; ?> €</span> </h3></center>
139 <br><?php
140 foreach($new_array as $key => $value){//here i foreach the array i made, $key mean name and $value means value, it will be summed.
141 echo "<center><h3>I owe to $key: $value €</h3></center>";
142 };
143 ?>
144
145<!DOCTYPE html>
146<html lang="en">
147<head>
148 <meta charset="UTF-8">
149 <title>Sulik App</title>
150 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.css">
151 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
152 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script>
153 <style type="text/css">
154 body {
155 background-image: url(1.jpg);
156 font-size:16px;
157 }
158 .wrapper{
159 width: 850px;
160 margin: 0 auto;
161 }
162 .page-header h2{
163 margin-top: 0;
164 }
165 table tr td:last-child a{
166 margin-right: 15px;
167 color:blue;
168 font-size: 20px
169 }
170 </style>
171 <script type="text/javascript">
172 $(document).ready(function(){
173 $('[data-toggle="tooltip"]').tooltip();
174 });
175 </script>
176</head>
177<body>
178 <div class="wrapper">
179 <div class="container-fluid">
180 <div class="row">
181 <div class="col-md-12">
182 <div class="page-header clearfix">
183 <h2 class="pull-left">Jacopo</h2>
184 <a href="index.php" class="btn btn-danger pull-right">Go Back</a>
185
186
187 </div>
188 <?php
189 $name = 'Jacopo';
190 $new_array = array();
191 // Include config file
192 require_once 'config.php';
193
194 // Attempt select query execution
195 $sql = "SELECT * FROM `payments` WHERE `check_list` IN ('Jacopo' , 'Suleyman,Jacopo' , 'Everybody' , 'Jacopo,Denis', 'Jacopo,Angus' )";
196 if($result = mysqli_query($link, $sql)){
197 if(mysqli_num_rows($result) > 0){
198 echo "<table class='table table-bordered table-striped'>";
199 echo "<thead>";
200 echo "<tr>";
201 echo "<th>#</th>";
202 echo "<th>Who paid for it</th>";
203 echo "<th>Date of payment</th>";
204 echo "<th>Payment name</th>";
205 echo "<th>How much</th>";
206 echo "<th>My Debt</th>";
207 $total_qty = 0;
208 echo "<th>Action</th>";
209 echo "</tr>";
210 echo "</thead>";
211 echo "<tbody>";
212 while($row = mysqli_fetch_array($result)){
213 echo "<tr>";
214 echo "<td>" . $row['id'] . "</td>";
215 echo "<td>" . $row['name'] . "</td>";
216 echo "<td>" . $row['dates'] . "</td>";
217 echo "<td>" . $row['product'] . "</td>";
218 echo "<td>" . $row['amount'] . " €". "</td>";
219 if($row['name'] == 'Jacopo'){echo "<td>" . 0 . " €". "</td>";}else{
220 echo "<td>" . $row['Jac'] . " €". "</td>";};
221 if($row['name'] == 'Jacopo'){;}else{
222 $total_qty += $row['Jac'];};
223 if($row['name'] == 'Jacopo'){/*do nothing*/}else{
224 if(isset($new_array[$row['name']])){//here i checked if the array key exists like $new_array['Jacopo']
225 $new_array[$row['name']] += $row['Jac'];//if exists sum the old value with the new one
226 }else{
227 $new_array[$row['name']] = $row['Jac'];//else put it in the array as new value with new key
228 }
229 }
230
231 echo "<td>";
232 echo "<a href='image.php?id=" ."' title='Add Check' data-toggle='tooltip'><span class='glyphicon glyphicon-upload'></span></a>";
233
234 echo "<a href='jacupdate.php?id=". $row['id'] ."' title='Edit My Debt' data-toggle='tooltip'><span class='glyphicon glyphicon-edit'></span></a>";
235
236 echo "</td>";
237 echo "</tr>";
238 }
239 echo "</tbody>";
240 echo "</table>";
241 // Free result set
242 mysqli_free_result($result);
243 } else{
244 echo "<p class='lead'><em>No records were found.</em></p>";
245 }
246 } else{
247 echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
248 }
249
250 // Close connection
251 mysqli_close($link);
252 ?>
253 </div>
254 </div>
255 </div>
256 </div>
257 <center><h3>Total Debt: <?php if (!empty($total_qty)) { echo $total_qty;}; ?> €</span> </h3></center>
258 <br><?php
259 foreach($new_array as $key => $value){//here i foreach the array i made, $key mean name and $value means value, it will be summed like you want.
260 echo "<center><h3>I owe to $key: $value €</h3></center>";
261 }
262 ?>
263</body>
264</html>