Jump to content

Banking System Blues


Antoine_Banks

Recommended Posts

Ok. So, I'm working on a family banking system, but, I'm having a few problems with some of the code:

 

ministatements.php

I have two accounts numbers 123456789 and 1234567890.

- 1234567890 has the following balance:

  • Primary: Yes
  • Account Balance: 2000000.00
  • Unclear Balance: 1000000.00
  • Accured Interest: 1000.00

- 123456789 has the following balance:

  • Primary: No
  • Account Balance: 1050000.00
  • Unclear Balance: 100.00
  • Accured Interest: 500.00

However, no matter what account number I choose, it only pulls the information from the primary account.

 

Here is the following code and screenshots:

<?php
session_start();
include("header.php");
include("dbconnection.php");
//include("functions/inactive_session_logout.php");

if(!($_SESSION["customerid"]))
{
	/*echo '<p style="color: red;">
			This page has been accessed in error.<br>
			You will be redirected to the login page in 5 seconds.<br>
			If you are not redirected, please
			<a href="emplogin.php">Click Here</a> to redirect.
			</p>';
	header("Location: login.php");*/
}
$accarray = mysql_query("SELECT * FROM accounts");

while($arrow = mysql_fetch_array($accarray))
{
	$acno = $arrow[accno];
	$prime = $arrow[primaryacc];
	$accbal = $arrow[accountbalance];
}
$trans = mysql_query("SELECT * FROM transaction");

while($rows = mysql_fetch_array($trans))
{
	$transdate = $rows[transactiondate];
	$part = $rows[particulars];
	$payee = $rows[payeeid];
	$receive = $rows[receiveid];
	$dep = $rows[depositac];
	$deb = $rows[debitac];
	$paystat = $rows[paymentstat];
}








$prime = $_POST[primaryacc];

if($prime == "yes")
{
	echo "primary";
}
$acc = mysql_query("SELECT * FROM accounts");
$trans = mysql_query("SELECT * FROM transaction");
$result = mysql_query("SELECT * FROM customers
						WHERE customers='$_SESSION[customerid]'");
?>
<link rel="stylesheet" type="text/css" href="css/form_style_view.css" />
<link rel="stylesheet" type="text/css" href="css/loan_nav.css" />
<div id="templatemo_main">
  <span class="main_top"></span>
	<div id="templatemo_content">
	<?php
	if(isset($_POST[submit]))
	{
	?>
	  <h2>Mini Statements</h2>
	  <form id="form1" name="form1" method="post" action="">
		<div class="m" style=" width:399px;">
		  <div style="text-align:center; border:0px;
		   border-bottom:1px solid #000;">
			<strong>
			  Balance Details - <?php echo $_SESSION[customername]; ?> -
				  [Details on <?php echo date("d-m-Y"); ?>]
			</strong>
		  </div>
		  <div class="l" style="border:0px;
			border-right:1px solid #000; width:130px;">
			<strong>Account Number</strong> 
		  </div>
		  <div class="r" style="border:0px;
			border-bottom:1px solid #000;"> 
			<?php echo $acno; ?> <?php echo $prime; ?>
		  </div>
		  <div class="clear"></div>
		  <div class="l" style="border:0px; border-top:1px solid #000;
			 border-right:1px solid #000; width:130px;">
			<strong>Account Balance</strong> 
		  </div>
		  <div class="r" style="border-top:1px #000 solid;
			border:0px;">
			 <?php echo $accbal; ?> 
		  </div>
		  <div class="clear"></div>
		</div>
		<p> </p>
		<div class="m" style="width:794px;">
		  <div style="text-align:center; width:785px;">
			<strong>Transaction Made</strong>
		  </div>
		  <div id="nav" style="width:795px;
		   border:0px; background-color:#CCCCCC;">
			<div class="col1" style="width:130px;
			 border-left:0px; border-bottom:0px;">
			  <strong>Transaction Date</strong>
			</div>
			<div class="col2" style="width:80px;
			 border-left:0px; border-bottom:0px;">
			  <strong>Particulars</strong>
			</div>
			<div class="col3" style="width:90px;
			 border-left:0px; border-bottom:0px;">
			  <strong>Payee ID</strong>
			</div>
			<div class="col4" style="width:90px;
			 border-left:0px; border-bottom:0px;">
			  <strong>Receiver ID</strong>
			</div>
			<div class="col5" style="width:90px;
			 border-left:0px; border-bottom:0px;">
			  <strong>Deposits</strong>
			</div>
			<div class="col6" style="width:90px;
			 border-left:0px; border-bottom:0px;">
			  <strong>Withdraws</strong>
			</div>
			<div class="col7" style="width:100px;
			 border-left:0px; border-bottom:0px;">
			  <strong>Balance</strong>
			</div>
			<div class="col8" style="width:116px;
			 border-left:0px; border-bottom:0px;">
			  <strong>Payment Stats</strong>
			</div>
			<div class="clear"></div>
			<?php
			while($transaction = mysql_fetch_array($trans))
			{
				echo "<div>
						<div class=\"row1\" style=\"width:130px;\">
						   $transdate
						</div>
						<div class=\"row2\" style=\"width:80px;
						 border-left:0px;\"> $part
						</div>
						<div class=\"row3\" style=\"width:90px;
						 border-left:0px;\"> $payee
						</div>
						<div class=\"row4\" style=\"width:90px;
						 border-left:0px;\"> $receive
						</div>
						<div class=\"row5\" style=\"width:90px;
						 border-left:0px;\"> $dep
						</div>
						<div class=\"row6\" style=\"width:90px;
						 border-left:0px;\"> $deb
						</div>
						<div class=\"row7\" style=\"width:100px;
						 border-left:0px;\"> $accbal
						</div>
						<div class=\"row8\" style=\"width:116px;
						 border-left:0px;\"> $paystat
						</div>
					  </div>";
			}
			?>
		  </div>
		</div>
	  </form>
	<?php
	}
	else
	{
	?>
	  <form id="form1" name="form1" method="POST" action="">
		<div class="m" style="width:398px;">
		  <div style="text-align:center; border-bottom:1px solid #000;">
			<strong>Select an Account Number</strong>
		  </div>
		  <div style="border:0px;">
			<div class="l" style="width:130px; border:0px;">
			  <label for="accno">
				<strong>Account Number</strong>
			  </label> 
			</div>
			<div class="r" style="width:264px; border:0px;">
			   
			  <select name="accno" id="accno">
				<option value="">Select Account Number</option>
				<?php
				while($rowsacc = mysql_fetch_array($acc))
				{
					echo "<option value='$rowsacc[accno] : $prime'>
							$rowsacc[accno] : $prime
						  </option>";
				}
				?>
			  </select> 
			  <input type="submit" name="submit"
			   id="submit" value="Submit" />
			</div>
		  </div>
		  <div class="clear"></div>
		</div>
	  </form>
	<?php
	}
	?>
	<p> </p>
	<p> </p>
	<div class="cleaner_h30"></div>
	<div class="cleaner_h60"></div>
  </div><!-- end of content -->
  <div id="templatemo_sidebar">
	<?php
	include("myaccountssidebar.php");
	?>
	<div class="cleaner_h40"></div>
	<h2> </h2>
  </div>
  <div class="cleaner"></div>
</div><!-- end of main -->
<div id="templatemo_main_bottom"></div><!-- end of main -->
<?php
include("footer.php");
?>

post-165393-0-51224800-1381207521_thumb.jpg

post-165393-0-40795300-1381207634_thumb.jpg

Link to comment
Share on other sites



<?php
session_start();
include("header.php");
include("dbconnection.php");
//include("functions/inactive_session_logout.php");


if(!($_SESSION["customerid"]))
{
/*echo '<p style="color: red;">
This page has been accessed in error.<br>
You will be redirected to the login page in 5 seconds.<br>
If you are not redirected, please
<a href="emplogin.php">Click Here</a> to redirect.
</p>';
header("Location: login.php");*/
}
$accarray = mysql_query("SELECT * FROM accounts WHERE customers='$_SESSION[customerid]'");


while($arrow = mysql_fetch_array($accarray))
{
$acno = $arrow[accno];
$prime = $arrow[primaryacc];
$accbal = $arrow[accountbalance];
}
$trans = mysql_query("SELECT * FROM transaction WHERE customers='$_SESSION[customerid]'");


while($rows = mysql_fetch_array($trans))
{
$transdate = $rows[transactiondate];
$part = $rows[particulars];
$payee = $rows[payeeid];
$receive = $rows[receiveid];
$dep = $rows[depositac];
$deb = $rows[debitac];
$paystat = $rows[paymentstat];
}
















$prime = $_POST[primaryacc];


if($prime == "yes")
{
echo "primary";
}
$acc = mysql_query("SELECT * FROM accounts WHERE customers='$_SESSION[customerid]'");
$trans = mysql_query("SELECT * FROM transaction WHERE customers='$_SESSION[customerid]'");
$result = mysql_query("SELECT * FROM customers
WHERE customers='$_SESSION[customerid]'");
?>
<link rel="stylesheet" type="text/css" href="css/form_style_view.css" />
<link rel="stylesheet" type="text/css" href="css/loan_nav.css" />
<div id="templatemo_main">
  <span class="main_top"></span>
<div id="templatemo_content">
<?php
if(isset($_POST[submit]))
{
?>
 <h2>Mini Statements</h2>
 <form id="form1" name="form1" method="post" action="">
<div class="m" style=" width:399px;">
 <div style="text-align:center; border:0px;
  border-bottom:1px solid #000;">
<strong>
 Balance Details - <?php echo $_SESSION[customername]; ?> -
 [Details on <?php echo date("d-m-Y"); ?>]
</strong>
 </div>
 <div class="l" style="border:0px;
border-right:1px solid #000; width:130px;">
<strong>Account Number</strong> 
 </div>
 <div class="r" style="border:0px;
border-bottom:1px solid #000;"> 
<?php echo $acno; ?> <?php echo $prime; ?>
 </div>
 <div class="clear"></div>
 <div class="l" style="border:0px; border-top:1px solid #000;
border-right:1px solid #000; width:130px;">
<strong>Account Balance</strong> 
 </div>
 <div class="r" style="border-top:1px #000 solid;
border:0px;">
 <?php echo $accbal; ?> 
 </div>
 <div class="clear"></div>
</div>
<p> </p>
<div class="m" style="width:794px;">
 <div style="text-align:center; width:785px;">
<strong>Transaction Made</strong>
 </div>
 <div id="nav" style="width:795px;
  border:0px; background-color:#CCCCCC;">
<div class="col1" style="width:130px;
border-left:0px; border-bottom:0px;">
 <strong>Transaction Date</strong>
</div>
<div class="col2" style="width:80px;
border-left:0px; border-bottom:0px;">
 <strong>Particulars</strong>
</div>
<div class="col3" style="width:90px;
border-left:0px; border-bottom:0px;">
 <strong>Payee ID</strong>
</div>
<div class="col4" style="width:90px;
border-left:0px; border-bottom:0px;">
 <strong>Receiver ID</strong>
</div>
<div class="col5" style="width:90px;
border-left:0px; border-bottom:0px;">
 <strong>Deposits</strong>
</div>
<div class="col6" style="width:90px;
border-left:0px; border-bottom:0px;">
 <strong>Withdraws</strong>
</div>
<div class="col7" style="width:100px;
border-left:0px; border-bottom:0px;">
 <strong>Balance</strong>
</div>
<div class="col8" style="width:116px;
border-left:0px; border-bottom:0px;">
 <strong>Payment Stats</strong>
</div>
<div class="clear"></div>
<?php
while($transaction = mysql_fetch_array($trans))
{
echo "<div>
<div class=\"row1\" style=\"width:130px;\">
  $transdate
</div>
<div class=\"row2\" style=\"width:80px;
border-left:0px;\"> $part
</div>
<div class=\"row3\" style=\"width:90px;
border-left:0px;\"> $payee
</div>
<div class=\"row4\" style=\"width:90px;
border-left:0px;\"> $receive
</div>
<div class=\"row5\" style=\"width:90px;
border-left:0px;\"> $dep
</div>
<div class=\"row6\" style=\"width:90px;
border-left:0px;\"> $deb
</div>
<div class=\"row7\" style=\"width:100px;
border-left:0px;\"> $accbal
</div>
<div class=\"row8\" style=\"width:116px;
border-left:0px;\"> $paystat
</div>
 </div>";
}
?>
 </div>
</div>
 </form>
<?php
}
else
{
?>
 <form id="form1" name="form1" method="POST" action="">
<div class="m" style="width:398px;">
 <div style="text-align:center; border-bottom:1px solid #000;">
<strong>Select an Account Number</strong>
 </div>
 <div style="border:0px;">
<div class="l" style="width:130px; border:0px;">
 <label for="accno">
<strong>Account Number</strong>
 </label> 
</div>
<div class="r" style="width:264px; border:0px;">
  
 <select name="accno" id="accno">
<option value="">Select Account Number</option>
<?php
while($rowsacc = mysql_fetch_array($acc))
{
echo "<option value='$rowsacc[accno] : $prime'>
$rowsacc[accno] : $prime
 </option>";
}
?>
 </select> 
 <input type="submit" name="submit"
  id="submit" value="Submit" />
</div>
 </div>
 <div class="clear"></div>
</div>
 </form>
<?php
}
?>
<p> </p>
<p> </p>
<div class="cleaner_h30"></div>
<div class="cleaner_h60"></div>
  </div><!-- end of content -->
  <div id="templatemo_sidebar">
<?php
include("myaccountssidebar.php");
?>
<div class="cleaner_h40"></div>
<h2> </h2>
  </div>
  <div class="cleaner"></div>
</div><!-- end of main -->
<div id="templatemo_main_bottom"></div><!-- end of main -->
<?php
include("footer.php");
?>


 

 

Try this

Link to comment
Share on other sites

If you do this

while($rows = mysql_fetch_array($trans))
{
	$transdate = $rows[transactiondate];
	$part = $rows[particulars];
	$payee = $rows[payeeid];
	$receive = $rows[receiveid];
	$dep = $rows[depositac];
	$deb = $rows[debitac];
	$paystat = $rows[paymentstat];
}

then the contents of the variables get overwritten each time you read the next row so you are only left with whatever was in the last row. The output needs to be inside the loop.

while($rows = mysql_fetch_array($trans))
{
	$transdate = $rows[transactiondate];
	$part = $rows[particulars];
	$payee = $rows[payeeid];
	$receive = $rows[receiveid];
	$dep = $rows[depositac];
	$deb = $rows[debitac];
	$paystat = $rows[paymentstat];

        // output the data from the row
}
Link to comment
Share on other sites

@Barand: Thanks for replying. However, I need the transactions to show based on the id of the account number chosen.

 

Unfortunately, no matter what account number I choose, it ONLY shows from the primary number. I want it to be able to switch depending on what account number is chosen from the dropdown menu.

 

Attached is more detail about the primary account information, so you can get an idea of what it supposed to do when any account number is chosen.

post-165393-0-96707000-1381219603_thumb.png

post-165393-0-16379600-1381219627_thumb.png

Link to comment
Share on other sites

You need to add a WHERE clause to your SELECT statements that limit it to only pulling rows associated with a particular account. In addition, when looping the results for the transactions you need to either output the records during the loop or store them into an array so that you get all transactions rather than just the last one.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.