-
Notifications
You must be signed in to change notification settings - Fork 0
/
accountTransfers.php
52 lines (40 loc) · 1.21 KB
/
accountTransfers.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
<?php
/**
* Created by PhpStorm.
* User: Filipe
* Date: 27/06/17
* Time: 19:01
*/
require 'dbConnect.php';
$db = pg_connect( pg_connection_string() );
//$userid=$_REQUEST['userid'];
//$cookie_name = "userid";
//$cookie_value = "1";
//setcookie( $cookie_name , $cookie_value,time() + (86400 * 30), "/");
//echo "<br />";
$user=$_COOKIE["user"];
if(!$db) {
//echo "ERROR OPENING DB";
} else {
//echo("<p style='color:darkcyan'> 'Opened database successfully\n'</p>");
}
//Ver movimentos
$sql =<<<EOF
SELECT * from TRANSFERS where account1='$user' OR account2='$user' ORDER BY created_at DESC;
EOF;
$ret = pg_query($db, $sql);
if(!$ret) {
echo pg_last_error($db);
exit;
}
while($row = pg_fetch_row($ret)) {
$date = date_create($row[4]);
if ($row[1]==$user){
echo("<tr><td>".date_format($date, 'Y-m-d H:i')."</td><td>".$row[1]."</td><td>".$row[2]."</td><td class='text-right'>".$row[3]." €</td></tr>");
//echo("<script>".$row[4].".slice(0,indexOf('.');</script>");
}elseif ($row[2]==$user){
echo("<tr><td>".date_format($date, 'Y-m-d H:i')."</td><td>".$row[1]."</td><td>".$row[2]."</td><td class='text-right'>".$row[3]." €</td></tr>");
}
}
pg_close($db);
?>