28, May 2012

For loop issue - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: For loop issue
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: For loop issue  (Read 1347 times)
Sandwich Artist
*
Posts: 25
186 credits
Members referred : 0


« on: Feb 28, 2008, 11:50:37 pm »

On a particular portion of my page I'm displaying all of the liabilities for the particular customer by having a for loop run through all of the data found from the sql query...everything displays fine but I want to have a delete button for each row so that we can remove anything that we may not need, or shouldn't be included in the file.  the problem is that the I can't seem to get the hidden fields that go with each button to store the ID of that row to work.  It only passes the last ID of the last row no matter which button you click on...Here's my code so far

Code:
<?php
while($row_Liabilities mysql_fetch_array($result_Liabilities))
{
?>

<tr bgcolor="white">
<td align="center">
   <a href="javascript:Popup('editLiab.php?ID=<? echo $row_Liabilities['ID'] ?>');" ><font color="blue">Edit</font></a>
</td>
<td align="center">
   <input type="submit" name="DeleteLiab" value="Delete Liab">
   <input type="hidden" name="liabID" value="<?php echo $row_Liabilities['ID']; ?>">
</td>
<td align="center"><?php echo $row_Liabilities['AccountType']; ?></td>
<td align="center"><?php echo $row_Liabilities['CreditorName']; ?></td>
<td align="center"><?php echo $row_Liabilities['AccountIdentifier']; ?></td>
<td align="center"><?php echo $row_Liabilities['AccountStatusType']; ?></td>
<td align="center"><?php echo number_format($row_Liabilities['UnpaidBalanceAmount'], 2"."","); ?></td>
<td align="center"><?php echo number_format($row_Liabilities['MonthlyPaymentAmount'], 2"."","); ?></td>
<?php
if($row_Liabilities['MonthsLeft'] == '')
{
$MonthsLeft ceil($row_Liabilities['UnpaidBalanceAmount'] / $row_Liabilities['MonthlyPaymentAmount']);
}
else
{
$MonthsLeft $row_Liabilities['MonthsLeft'];
}
?>

<td align="center"><?php echo $MonthsLeft?></td>
<td align="center"><?php echo $row_Liabilities['PastDueAmount']; ?></td>
</tr>
<?php
//Get totals for display
$TotalBalance $TotalBalance $row_Liabilities['UnpaidBalanceAmount'];
$TotalMonthlyPmt $TotalMonthlyPmt $row_Liabilities['MonthlyPaymentAmount'];
}
//end while $row_Liabilities

The javascript for the popup edit window works properly and opens the correct item based on the ID, but the buttons all use the ID of the last row no matter what...Just doesn't make sense to me...any suggestions?
« Last Edit: Feb 29, 2008, 11:50:44 am by Nikolas »
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #1 on: Feb 29, 2008, 12:04:12 pm »

You just need to open and close a form element in every record. So this :

<input type="submit" name="DeleteLiab" value="Delete Liab">
<input type="hidden" name="liabID" value="<?php echo $row_Liabilities['ID']; ?>">

should become :

<form method="..." action="....">
   <input type="submit" name="DeleteLiab" value="Delete Liab">
   <input type="hidden" name="liabID" value="<?php echo $row_Liabilities['ID']; ?>">
</form>

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=7618
Tags : php hidden field for loop Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: For loop issue
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 09:55:37 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.