Link to home
Start Free TrialLog in
Avatar of aduvall
aduvall

asked on

How do I loop through a posted array?

I have an array I am POSTING from flex.

$pizza  = $_POST['cust'];// the posted array(cusa, cusb, cusc, etc...)
$pieces = explode(",", $pizza);//this part seems fine.

I need to run this formula based on the posted data.  At this time I am doing this.

$creport->RecordSelectionFormula = "{ar_invl.cust-no} in ['".$pieces[0]."','".$pieces[1]."','".$pieces[2]."','".$pieces[3]."','".$pieces[4]."','".$pieces[5]."'] and {ar_invl.inv-date} in Date (".$start.") to Date (".$end.")";
Isn't there some sort of loop I can contstruct so I do not need to keep adding vars to this formula?

I have tried this but it does not seem to work. I would like to solve this problem as I have had issues with this for some time. Any help appreciated.
for($i=0; $i<$pieces; $i++){
$creport->RecordSelectionFormula = "{ar_invl.cust-no} in ['".$pieces[$i]."'] and {ar_invl.inv-date} in Date (".$start.") to Date (".$end.")";
}

SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aduvall
aduvall

ASKER

Hello, Thanks for the help.  With the fiist response it works and I get this.
{ar_invl.cust-np} in ['SON","SONINTL","TOSHIBA","UPS 3D","UPS ABB","UPS CORN","UPS FUJI","UPS OTN","UPS PMED","UPS/INDY'] and {ar_invl.inv-date} in Date(2008, 01, 09) to Date (2008, 01, 16) this works fine but I need everything in double quotes. As you can see the begining starts with a single quote and the last item ends with a single quote.  How do I make these all double?  "TOSHIBA", "LGE", "WWT" etc....

On the second response I only get the last item in the array.  Why would this be?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial