[RESOLVED] Capturing array data from $_POST-VBForums
Results 1 to 2 of 2

Thread: [RESOLVED] Capturing array data from $_POST

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    London
    Posts
    107

    Resolved [RESOLVED] Capturing array data from $_POST

    I have a form with an update button (btnupdate), which, when clicked triggers the php script 'select_issue3'php'. This is the section of code that I'm struggling with:

    if (isset($_POST["btnupdate"]))
    {
    include_once('reduced_view_issues.php');

    foreach ($_POST["issueid"] as $sKey =>$iLine) {

    $test=$_POST['issueid'][$iLine];

    echo $test;

    var_dump($_POST);

    }

    What I was hoping to do here, is, for each array posted, align each row[0] so that issueid[0] corresponds to randomfieldname[0] and so on.

    In the code so far, I was just trying to see if my approach was working, hence it only has the one field.

    The above code returns nothing, although the data is posting, as per the var_dump below:

    array(40) { ["btnupdate"]=> string(11) "Update Bond" ["bonddescription2"]=> array(1) { [0]=> string(16) "RBS 7.000 8/2023" } ["issueid"]=> array(1) { [0]=> string(2) "87" } ["notes"]=> array(1) { [0]=> string(0) "" } ["currency_id"]=> array(1) { [0]=> string(1) "1" } ["coupon"]=> array(1) { [0]=> string(5) "7.000" } ["coupon_type_id"]=> array(1) { [0]=> string(1) "1" } ["coupon_frequency_id"]=> array(1) { [0]=> string(1) "2" } ["day_count_id"]=> array(1) { [0]=> string(1) "4" } ["price_to_id"]=> array(1) { [0]=> string(1) "2" } ["quote_convention_id"]=> array(1) { [0]=> string(1) "2" } ["issuer_id"]=> array(1) { [0]=> string(1) "1" } ["guarantor_id"]=> array(1) { [0]=> string(1) "1" } ["sub_sector_id"]=> array(1) { [0]=> string(1) "1" } ["market_id"]=> array(1) { [0]=> string(13) "None Selected" } ["cusip"]=> array(1) { [0]=> string(4) "TEST" } ["bloomberg_number"]=> array(1) { [0]=> string(4) "TEST" } ["isin"]=> array(1) { [0]=> string(10) "XSTESTISIN" } ["moody"]=> array(1) { [0]=> string(0) "" } ["fitch"]=> array(1) { [0]=> string(0) "" } ["sandp"]=> array(1) { [0]=> string(0) "" } ["capital_id"]=> array(1) { [0]=> string(13) "None Selected" } ["collateral_type_id"]=> array(1) { [0]=> string(13) "None Selected" } ["issue_benchmark_id"]=> array(1) { [0]=> string(13) "None Selected" } ["current_benchmark_id"]=> array(1) { [0]=> string(13) "None Selected" } ["issue_swap_spread"]=> array(1) { [0]=> string(6) "50.000" } ["issue_benchmark_spread"]=> array(1) { [0]=> string(6) "60.000" } ["issue_price"]=> array(1) { [0]=> string(6) "99.000" } ["coupon_step"]=> array(1) { [0]=> string(0) "" } ["announcement_date"]=> array(1) { [0]=> string(0) "" } ["interest_accrual_date"]=> array(1) { [0]=> string(0) "" } ["first_settle_date"]=> array(1) { [0]=> string(0) "" } ["first_coupon_date"]=> array(1) { [0]=> string(0) "" } ["maturity_date"]=> array(1) { [0]=> string(10) "2023-08-09" } ["first_call_date"]=> array(1) { [0]=> string(0) "" } ["amount_issued"]=> array(1) { [0]=> string(8) "10000000" } ["amount_outstanding"]=> array(1) { [0]=> string(8) "10000000" } ["min_size"]=> array(1) { [0]=> string(0) "" } ["increment"]=> array(1) { [0]=> string(0) "" } ["par_amount"]=> array(1) { [0]=> string(0) "" } }

    As the data seems to be posting, presumably the error is in the way I am trying to capture and manipulate the data?

    I'm hoping a kind soul is able to point out where my error(s) lie :-)

  2. #2

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    London
    Posts
    107

    Re: Capturing array data from $_POST

    I don't know if this is the neatest way...but this seems to work:

    if (isset($_POST["btnupdate"]))
    {
    include_once('reduced_view_issues.php');

    $irow=0;
    foreach ($_POST['issueid'] as $result) {

    $issueid =$_POST['issueid'][$irow];
    $bonddescription2=$_POST['bonddescription2'][$irow];

    echo $issueid."-".$bonddescription2;

    }
    $irow++;

    include_once('select_issue.php');

    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.