Jump to content

Membership Page with transactions of accounts


carlito.way00

Recommended Posts

I have removed the pagination page so I could use while loop to create this membership page but the while loop  counter does not update if a transaction page is carried out. rather it updates the row of the last transaction with the current transaction.

 

Help needed will be appreciated for the code below:

<?php
$sql = "SELECT * FROM  members WHERE username='".$_SESSION['username']."'";
$result = mysql_query($sql);
echo "<table width = '90%' border = '1' align = 'center'>";
echo "<tr>";
echo "<th width = '5%' height = '20' align = 'center'>No</th>";
echo "<th width = '10%' height = '20' align = 'center'>Date</th>";
echo "<th width = '13%' height = '20' align = 'center'>Amount($)</th>";
echo "<th width = '15%' height = '20' align = 'center'>Balance($)</th>";
echo "<th width = '10%' height = '20' align = 'center'>Charges($)</th>";
echo "<th width = '15%' height = '20' align = 'center'>Transaction Type</th>";
echo "<th width = '10%' height = '20' align = 'center'>Status</th></tr>";
$counter = 1;	 
while  ($row = mysql_fetch_array($result))
{
   $statementdate = $row["statementdate"];
   $amounttransact = $row["amounttransact"];
   $acctbal = $row["acctbal"];
   $charges = $row["charges"];
   $transctype = $row["transctype"];
   $transtatus = $row["transtatus"];
   echo "<tr>";
   echo "<td align = 'center'>$counter</td>";
   echo "<td align = 'center'>".$fetch_users_data->statementdate."</td>";
   echo "<td align = 'center'>".$fetch_users_data->amounttransact."</td>";
   echo "<td align = 'center'>".$fetch_users_data->acctbal."</td>";
   echo "<td align = 'center'>".$fetch_users_data->charges."</td>";
   echo "<td align = 'center'>".$fetch_users_data->transctype."</td>";
   echo "<td align = 'center'>".$fetch_users_data->transtatus."</td></tr>";
   $counter++;	
}	
echo "</table>";
?>

 

 

Why are you doing this:

".$fetch_users_data->statementdate."

 

  echo "<td align = 'center'>".$statementdate."</td>";

should do it.

 

Even simpler:

  echo "<td align = 'center'>".$row['statementdate']."</td>";

should do it, making the variables redundant.

 

if you start the counter at 1, and increment after pulling out each row, counter will always be number_of_results+1.

 

so if you only pull out one row, counter will say 2.

 

(I'm just saying, maybe it's deliberate, in that case I apologize for buggin' you)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.