carlito.way00 Posted June 28, 2011 Share Posted June 28, 2011 @anyone I have installed a pagination page on my membership page to make a balance sheet in a way to see transaction details, I am currently working on a project to build an online bank project, when I update mysql with a new data, I am expected to get a new row, but rather I see the old row has been re-written by the update of the mysql result. How can I solve this problem and below is my membership page. ------------------------------------------------------------------------------------------------------------------------------------------------ <?php session_start(); include_once"config.php"; if(!isset($_SESSION['username']) || !isset($_SESSION['password'])){ header("Location: login.php"); }else{ $fetch_users_data = mysql_fetch_object(mysql_query("SELECT * FROM `members` WHERE username='".$_SESSION['username']."'")); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>X-Bank Members Page</title> </head> <body> <table width="100%" border="1" cellspacing="1" cellpadding="1"> <tr> <td width="33%">You are logged as <?php echo "".$fetch_users_data->username."";?></div></td> <td width="34%">Last IP Logged :</td> <td width="33%">Your Account Balance is : $ <?php echo "".$fetch_users_data->acctbal."";?></div></td> </tr> </table> <br /> <table width="100%" height="253" border="0" cellpadding="1" cellspacing="1"> <tr valign="top"> <td width="21%" height="205"><table width="100%" border="1" cellspacing="1" cellpadding="1"> <tr> <td><div align="center"><a href="members.php" >Home</a></div></td> </tr> </table> <table width="100%" border="1" cellspacing="1" cellpadding="1"> <tr> <td><div align="center"><a href="profile.php">Members Profile</a></div></td> </tr> </table> <table width="100%" border="1" cellspacing="1" cellpadding="1"> <tr> <td><div align="center"><a href="changepass.php">Change Password</a></div></td> </tr> </table> <table width="100%" border="1" cellspacing="1" cellpadding="1"> <tr> <td><div align="center"><a href="billpayment.php">Bill Payment</a></div></td> </tr> </table> <table width="100%" border="1" cellspacing="1" cellpadding="1"> <tr> <td><div align="center"><a href="fundtransfer.php">Fund Tranfser</a></div></td> </tr> </table> <table width="100%" border="1" cellspacing="1" cellpadding="1"> <tr> <td><div align="center"><a href="loans.php">Loans</a></div></td> </tr> </table> <table width="100%" border="1" cellspacing="1" cellpadding="1"> <tr> <td><div align="center"><a href="logout.php">Logout</a></div></td> </tr> </table></td> <td width="79%" rowspan="2"><?php $page_name="members.php"; $start=$_GET['start']; if(strlen($start) > 0 and !is_numeric($start)){ echo "Data Error"; exit; } $eu = ($start -0); $limit = 2; $this1 = $eu + $limit; $back = $eu - $limit; $next = $eu + $limit; $query2=" SELECT * FROM members where username='".$_SESSION['username']."'"; $result2=mysql_query($query2); echo mysql_error(); $nume=mysql_num_rows($result2); $bgcolor="#f1f1f1"; echo "<TABLE width=90% align=center cellpadding=0 cellspacing=0> <tr>"; echo "<td bgcolor='dfdfdf' > Date</font></td>"; echo "<td bgcolor='dfdfdf' > Transaction Type</font></td>"; echo "<td bgcolor='dfdfdf' > Amount</font></td>"; echo "<td bgcolor='dfdfdf' > Initial Balance</font></td>"; echo "<td bgcolor='dfdfdf' > Charges</font></td>"; echo "<td bgcolor='dfdfdf' > Final Balance </font></td> </tr>"; $fetch_users_data = mysql_fetch_object(mysql_query("SELECT * FROM `members` WHERE username='".$_SESSION['username']."' limit $eu, $limit")); echo mysql_error(); { if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';} else{$bgcolor='#f1f1f1';} echo "<tr >"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->statementdate."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->statementtrasct."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->amounttransact."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->intacctbal."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->charges."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->acctbal."</font></td>"; echo "</tr>"; } echo "</table>"; $p_fwd=$p_f+$p_limit; $p_back=$p_f-$p_limit; echo "<table align = 'center' width='50%'><tr><td align='left' width='20%'>"; if($p_f<>0){print "<a href='$page_name?start=$p_back&p_f=$p_back'><font face='Verdana' size='2'>PREV $p_limit</font></a>"; } echo "</td><td align='left' width='10%'>"; if($back >=0 and ($back >=$p_f)) { print "<a href='$page_name?start=$back&p_f=$p_f'><font face='Verdana' size='2'>PREV</font></a>"; } echo "</td><td align=center width='30%'>"; for($i=$p_f;$i < $nume and $i<($p_f+$p_limit);$i=$i+$limit){ if($i <> $eu){ $i2=$i+$p_f; echo " <a href='$page_name?start=$i&p_f=$p_f'><font face='Verdana' size='2'>$i</font></a> "; } else { echo "<font face='Verdana' size='4' color=red>$i</font>";} } echo "</td><td align='right' width='10%'>"; if($this1 < $nume and $this1 <($p_f+$p_limit)) { print "<a href='$page_name?start=$next&p_f=$p_f'><font face='Verdana' size='2'>NEXT</font></a>";} echo "</td><td align='right' width='20%'>"; if($p_fwd < $nume){ print "<a href='$page_name?start=$p_fwd&p_f=$p_fwd'><font face='Verdana' size='2'>NEXT $p_limit</font></a>"; } echo "</td></tr></table>"; ?> </td> </tr> <tr valign="top"> <td height="43"> </td> </tr> </table> <p> </p> </body> </html> --------------------------------------------------------------------------------------------------------------------------------------------- will be glad if help will be rendered Quote Link to comment https://forums.phpfreaks.com/topic/240612-php-pagination/ Share on other sites More sharing options...
fugix Posted June 28, 2011 Share Posted June 28, 2011 since you wish to display more than one row, you will need to place you mysql_fetch_object() function inside of a while loop. Also, I recommend puting your query into a variable before using it inside of the function $result = mysql_query("SELECT * FROM `members` WHERE username='".$_SESSION['username']."' limit $eu, $limit"); while($fetch_users_data = mysql_fetch_object($result)) { if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';} else{$bgcolor='#f1f1f1';} echo "<tr >"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->statementdate."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->statementtrasct."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->amounttransact."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->intacctbal."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->charges."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->acctbal."</font></td>"; echo "</tr>"; echo "</table>"; } Edit: since "members" is not a mysql reserved word, you do not need to wrap it in backticks, however this is still acceptable Quote Link to comment https://forums.phpfreaks.com/topic/240612-php-pagination/#findComment-1235865 Share on other sites More sharing options...
KevinM1 Posted June 28, 2011 Share Posted June 28, 2011 In the future, please place code within or tags. Quote Link to comment https://forums.phpfreaks.com/topic/240612-php-pagination/#findComment-1235866 Share on other sites More sharing options...
carlito.way00 Posted June 28, 2011 Author Share Posted June 28, 2011 Thanks for the reply, I will heed to your advice but seems my problem is still not solved or maybe I am asking the wrong question . here is error I am facing currently If mysql database is updated I expect a new row to be automatically formed but rather it will wipe the old data and replace it with the new one which is not what I want. Thanks for your reply once again Quote Link to comment https://forums.phpfreaks.com/topic/240612-php-pagination/#findComment-1235880 Share on other sites More sharing options...
fugix Posted June 28, 2011 Share Posted June 28, 2011 placing the code in a while loop should fix the problem of only displaying one row, however I have realized an error that i made in the previous code, I placed the closing </table> tag inside of the while loop which I should not have done....try this instead. $result = mysql_query("SELECT * FROM `members` WHERE username='".$_SESSION['username']."' limit $eu, $limit"); while($fetch_users_data = mysql_fetch_object($result)) { if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';} else{$bgcolor='#f1f1f1';} echo "<tr >"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->statementdate."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->statementtrasct."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->amounttransact."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->intacctbal."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->charges."</font></td>"; echo "<td align=left bgcolor=$bgcolor id='title'> <font face='Verdana' size='2'>".$fetch_users_data->acctbal."</font></td>"; echo "</tr>"; //removed the </table> tag below } Quote Link to comment https://forums.phpfreaks.com/topic/240612-php-pagination/#findComment-1235884 Share on other sites More sharing options...
carlito.way00 Posted June 28, 2011 Author Share Posted June 28, 2011 Still didnt work..still changed my result rather than creating a new row. Quote Link to comment https://forums.phpfreaks.com/topic/240612-php-pagination/#findComment-1235895 Share on other sites More sharing options...
KevinM1 Posted June 28, 2011 Share Posted June 28, 2011 What query are you using to send your data to the database? Quote Link to comment https://forums.phpfreaks.com/topic/240612-php-pagination/#findComment-1235900 Share on other sites More sharing options...
carlito.way00 Posted June 28, 2011 Author Share Posted June 28, 2011 I guess I manually update the database based on my own understanding which might be wrong..but since you have asked..but I have a register form already that sends data to the database. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/240612-php-pagination/#findComment-1235904 Share on other sites More sharing options...
carlito.way00 Posted June 28, 2011 Author Share Posted June 28, 2011 What query are you using to send your data to the database? could that be why i am not getting my request? and once again thanks Quote Link to comment https://forums.phpfreaks.com/topic/240612-php-pagination/#findComment-1235909 Share on other sites More sharing options...
KevinM1 Posted June 28, 2011 Share Posted June 28, 2011 To be honest, I'm not entirely sure what your problem actually is. Are you trying to add a new row to the database, and it's merely updating an existing row? Are you trying to update an existing row, and it's creating a new row? Is your pagination working correctly for existing entries? Quote Link to comment https://forums.phpfreaks.com/topic/240612-php-pagination/#findComment-1235915 Share on other sites More sharing options...
carlito.way00 Posted June 28, 2011 Author Share Posted June 28, 2011 Yes my pagination is working.but i want to generate a statement table when a user clicks his/her member page after logon to. this statement table will retrieve data and display for the user to see and know about his transaction, Quote Link to comment https://forums.phpfreaks.com/topic/240612-php-pagination/#findComment-1235978 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.