carlito.way00 Posted July 1, 2011 Share Posted July 1, 2011 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>"; ?> Quote Link to comment Share on other sites More sharing options...
sunfighter Posted July 1, 2011 Share Posted July 1, 2011 Why are you doing this: ".$fetch_users_data->statementdate." echo "<td align = 'center'>".$statementdate."</td>"; should do it. Quote Link to comment Share on other sites More sharing options...
EdwinPaul Posted July 1, 2011 Share Posted July 1, 2011 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. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 1, 2011 Share Posted July 1, 2011 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) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.