-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpleDBCosts.php
More file actions
84 lines (61 loc) · 2.07 KB
/
simpleDBCosts.php
File metadata and controls
84 lines (61 loc) · 2.07 KB
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
<?php
session_start();
include "library/stdinc.php";
require_once(dirname(__FILE__).'/config/config.inc.php');
// error_reporting(0);
date_default_timezone_set('UTC');
$domain_name = htmlentities($_GET['id']);
// Connect to database
$db_server = mysql_connect(_DB_HOST_, _DB_USER_, _DB_PASS_);
if (!$db_server) die("Unable to connect to mySQL: " . mysql_error());
mysql_select_db(_DB_NAME_) or die ("Unable to select database: " . mysql_error());
?>
<!DOCTYPE HTML>
<html>
<head>
<title>SimpleDB - List Costs</title>
<link href="css/style.css" type=text/css rel=stylesheet>
</head>
<body>
<p><a href="index.php"><b>Amazon SimpleDB PHP Demo</b></a></p>
<p>A summary of the costs for running the SimpleDB PHP Demo are listed below.</p>
<?php
// Check database for users info
$query = "SELECT * FROM aws_costs ";
$query .= " ORDER BY aws_costs_id DESC ";
// echo "Query: $query<br>";
$result = mysql_query($query);
if (!$result) die ("Database access failed: " . mysql_error());
$rows = mysql_num_rows($result);
// echo "Rows: $rows<p>";
echo "<table>";
echo "<tr>";
echo "<td width=200 valign=top bgcolor=" . $adHeading . " align=left><strong>Date</strong></td>";
echo "<td width=400 valign=top bgcolor=" . $adHeading . " align=left><strong>Notes</strong></td>";
echo "<td width=100 valign=top bgcolor=" . $adHeading . " align=left><strong>Cost</strong></td>";
echo "</tr>";
$cCost = 0;
for ($j = 0; $j < $rows; ++$j)
{
If ($j % 2) {
$bgcolor = $adRow1;
} Else {
$bgcolor = $adRow2;
}
$row = mysql_fetch_row($result);
echo "<tr>";
echo "<td valign=top bgcolor=" . $bgcolor . ">$row[4]</td>";
echo "<td valign=top bgcolor=" . $bgcolor . ">$row[3]</td>";
echo "<td valign=top bgcolor=" . $bgcolor . ">" . number_format($row[2], 10) . "</td>";
echo "</tr>";
$cCost = $cCost + $row[2];
}
echo "</tr>";
echo "<tr>";
echo "<td colspan='2'><b>Total:</b></td>";
echo "<td><b>" . number_format($cCost, 10) . "</b></td>";
echo "<tr>";
echo "</table>";
?>
</body>
</html>