Jump to content

foreach statement and submit


Zyncmaster2006

Recommended Posts

Hi i got a foreach script that displays a something like this:

----------------------------------------------------------------------------------------------------
| | | | |
|  Name    | Monthly Payment      | Principal Amount  Interest    |
| | | | |
-----------------------------------------------------------------------------------------------------
| |
| ARON Jeff | 76125371273571253   |  1231231231    |        0.18  |
| | | | |
|Davis Genn | 89089808098098908   |  6786283764   |        0.18 |
| | | | |
| | | | |
|Steel, Max | 9787879797123423   | 2234587345  |        0.12 |
| | | | |
| | | | |
----------------------------------------------------------------------------------------------------

The reason why display it like that because i can't seem to attach the pciture version. Anyway, I created that form by using foreach. what i want to happen is how can i submit all that data althogether and store it in their designated tables in the database as shown above. 

here is the code:
<?php
global $session;

    $loan_type_ID = $_GET['loan_type_ID'];
$loan_accnt_ID = $_GET['loan_accnt_ID'];
$monthly = $_GET['amount_of_loan'];
$amount = $_GET['amount'];
$or_no = $_GET['or_no'];
$members = getMembers($session[loan_type_ID],$session[loan_accnt_ID]);

if(!$members)
{
print "No members yet.<p>";
return;
}

print"
<table width='852' border='0' cellspacing='2' cellpadding='4' class = 'header2'>
<tr>
    <td colspan='6'>OR no: $or_no </td>
  </tr>
  <tr><td width='68'><div align='center'>Paid</div></td>
    <td width='285'><div align='center'>Name</div></td>
    <td width='132'><div align='center'>Monthly Payment</div></td>
    <td width='110'><div align='center'>Principal</div></td>
    <td width='111'><div align='center'>Interest</div></td></tr>
  <tr>";
foreach ($members as $row)
{
print "<td><div align='center'>
          <input type='checkbox' name='col_paid' value='paid' />
      </div></td><td align='center'>
$row[last_name], $row[first_name] $row[mid_name] <br></a></td>
    <td><div align='center'><input name='form[amount]' type='text' class='ctrl' id='form[amount]' size='20' ></div></td>
    <td><div align='center'>$row[amount_of_loan]</div></td>
    <td><div align='center'><input name='form[interest_rate]' type='text' class='ctrl' id='form[interest_rate]' size='20' value=' $row[interest_rate]'></div></td>
</tr></form>";
}

echo "<tr>
    <td colspan='6'><div align='right'><a href=''></a>
      <label>
      <input type='submit' name='Submit' value='Submit' />
      </label>
    </div></td>
  </tr>
</table>";
?>

can it be done? or is there another way? pls help me.


Link to comment
https://forums.phpfreaks.com/topic/19730-foreach-statement-and-submit/
Share on other sites

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.