25, July 2008

For loop issue - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ 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

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


« on: Feb 29, 2008, 12:50:37 AM »

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, 12:50:44 PM by Nikolas »
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7975
40807 credits
Members referred : 3



« Reply #1 on: Feb 29, 2008, 01: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 Visit through proxy

Last blog : MIA - Where Nick and Tim
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....

Topic sponsors:
Get a permanent link here for $1.99!


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?
Jul 25, 2008, 12:14:31 AM





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!


Forum Statistics
Total Posts: 35.717
Total Topics: 7.379
Total Members: 3.711
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: Asimina

40 Guests, 4 Users online :

12 users online today:



Readers

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