Files
cs157AOnlineBanking/f8l_exception/my_accounts.php

70 lines
2.6 KiB
PHP
Raw Normal View History

<!-- F8L Exception Online Bank | My Accounts -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>F8L Exception Online Bank | My Accounts</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<?php include 'includes/inc_header.php'; ?>
2014-11-14 15:41:00 -08:00
</head>
<body>
2014-11-14 15:41:00 -08:00
<hr />
<h1>My Accounts</h1>
<?php
2014-11-16 23:34:19 -08:00
include 'functions.php';
function showAccounts($userName) {
// Select database.
2014-11-16 23:34:19 -08:00
$result = queryMysql("SELECT * from account WHERE username='$userName'");
2014-12-04 16:16:02 -08:00
2014-11-16 23:34:19 -08:00
if ($result->num_rows == 0){
2014-12-04 16:16:02 -08:00
echo "<div class='error'><p>You have no accounts open.</p></div>";
2014-11-16 23:34:19 -08:00
} else {
echo "<table width='50%' border='1'>";
echo "<tr>
<th>Account Type</th>
<th>Account Number</th>
<th>Balance</th>
2014-12-04 16:16:02 -08:00
<th>Interest Rate</th>
<th>Minimum Payment</th>
2014-11-16 23:34:19 -08:00
</tr>";
$num = $result->num_rows;
for ($j = 0; $j < $num; $j++){
$row = $result->fetch_array(MYSQLI_ASSOC);
2014-12-04 16:16:02 -08:00
echo "<tr><td>" . $row['acctype'] . "</td><td>" . $row['accid'] . "</td><td>$ " . number_format($row['balance'], 2, '.', ',') . "</td></tr>";
2014-11-16 23:34:19 -08:00
}
2014-12-04 16:16:02 -08:00
//Get Loan Info
$result = queryMysql("SELECT * from loan WHERE username='$userName'");
if ($result->num_rows > 0){
$num = $result->num_rows;
for ($j = 0; $j < $num; $j++){
$row = $result->fetch_array(MYSQLI_ASSOC);
echo "<tr><td>" . $row['acctype'] . "</td><td>" . $row['loanid'] . "</td><td>$ " . number_format($row['balance'], 2, '.',',') . "</td><td>$" . $row['interestrate'] . "</td></tr>";
}
}
//Get Credit Card Info
$result = queryMysql("SELECT * from creditcard WHERE username='$userName'");
if ($result->num_rows > 0){
$num = $result->num_rows;
for ($j = 0; $j < $num; $j++){
$row = $result->fetch_array(MYSQLI_ASSOC);
echo "<tr><td>" . $row['acctype'] . "</td><td>" . $row['creditid'] . "</td><td>$ " . number_format($row['balance'], 2, '.',',') . "</td><td>$" . $row['interestRate'] . "</td></tr>";
}
}
echo "</table>";
2014-11-16 23:34:19 -08:00
$result->close();
}
}
$userName = "";
$userName = $_SESSION['login'];
echo "User Name: ".$userName."<br />";
showAccounts($userName);
?>
</body>
</html>