Hutts Posted May 26, 2011 Share Posted May 26, 2011 Having a problem getting multiple orders on one invoice. Need to query entries from a database and add them to an order through the api. Tried this code $i = 0; while ($r=odbc_fetch_array($results)) { $postfields['pid[$i]'] = $r['pid']; $postfields['billingcycle[$i]'] = 'onetime'; $i++; } However this code only enters 1 item when there should be multiple. Manually entering $postfields['pid[0]'] = ....$postfields['pid[1]'] = .....does add the multiple orders. I need to do this dynamically tho seeing i have no idea exactly how many items. Tried a couple of different ways to set the $postfields[XXX] variables name but can't seem to get it to work. Any thoughts? 0 Quote Link to comment Share on other sites More sharing options...
Hutts Posted May 26, 2011 Author Share Posted May 26, 2011 (edited) Not sure if this is some funky bug or i'm doing something wrong ? Tried this for ($i = 0; $i <= 2; $i++) { $postfields['pid[$i]'] = 14 + $i; echo "postfields[$i]="; echo $postfields['pid[$i]']; echo ";"; } #$a = 3; #$b = 4; #$c = 5; #$postfields['pid[$a]'] = 14; #echo "postfields[$a]="; #echo $postfields['pid[$a]']; #echo ";"; #$postfields['pid[$b]'] = 15; #echo "postfields[$b]="; #echo $postfields['pid[$b]']; #echo ";"; #$postfields['pid[$c]'] = 16; #echo "postfields[$c]="; #echo $postfields['pid[$c]']; #echo ";"; ........ echo($data); Returns 1 item ordered postfields[0]=14;postfields[1]=15;postfields[2]=16;result=success;orderid=230;invoiceid=178;productids=240;addonids=;domainids=; Uncomment the above lines and the following gets returned (4 items) postfields[0]=14;postfields[1]=15;postfields[2]=16;postfields[3]=14;postfields[4]=15;postfields[5]=16;result=success;orderid=231;invoiceid=179;productids=241,242,243,244;addonids=;domainids=; Seems for some reason the api isn't getting the data assigned in the loop? Edited May 26, 2011 by Hutts 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.