shaunmacie Posted October 22, 2011 Share Posted October 22, 2011 Hi, I have an affiliate system that shows results on what product is purchased. The problem is that the tracker is only listing the first product in the purchase list, so if someone purchases multiple products it only shows the first product in the transaction report. Here is the code: $module = fetchDbConfig('PostAffiliatePro'); $orderInv = $order->getOrderInv($_GET["cart_order_id"]); print_r($orderInv); $affCode = "<!-- Begin PostAffiliatePro Affiliate Tracker --> <img border='0' src='".$module['URL']."/scripts/sale.php?TotalCost=".sprintf("%.2f", $orderSum['subtotal'])."&OrderID=".$cart_order_id."&ProductID=".$orderInv['0']['productCode']."' width='0' height='0' alt='' /> <!-- End PostAffiliatePro Affiliate Tracker -->"; ?> The code I need help with syntax is: "&ProductID=".$orderInv['0']['productCode']." The products are split into arrays by number (0,1,2,3). So for example, I would want to show results for .$orderInv['0']['productCode']. , then .$orderInv['1']['productCode']. , and so on. I would like the results to be posted with a ; between them, but I don't know the proper syntax to have it report more than just the first array. This seems pretty simple, but I only know the basics of PHP and I've adapted this from found code. Any guidance would be greatly appreciated. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/249599-php-multiple-variables-syntax-formatting-help/ Share on other sites More sharing options...
Pikachu2000 Posted October 22, 2011 Share Posted October 22, 2011 implode would work, but if you have control over both ends of the process, you'd probably be better off to serialize it so you can retain the structure of the array, if necessary. Quote Link to comment https://forums.phpfreaks.com/topic/249599-php-multiple-variables-syntax-formatting-help/#findComment-1281388 Share on other sites More sharing options...
shaunmacie Posted October 22, 2011 Author Share Posted October 22, 2011 Thanks, but I only have basic/limited knowledge of php - so I'd have no idea how to make that work without more guidance. The php of this shopping cart system is spread out across many files, so I wouldn't even know where to begin. I'm basically just looking for the easiest solution that my basic php skills can handle. I'm a graphic designer - I'll leave the complex coding to the php gods. Otherwise, my brain will explode Quote Link to comment https://forums.phpfreaks.com/topic/249599-php-multiple-variables-syntax-formatting-help/#findComment-1281398 Share on other sites More sharing options...
Pikachu2000 Posted October 22, 2011 Share Posted October 22, 2011 I guess I should have figured this is for a shopping cart. Typically, shopping carts are best handled with $_SESSION vars. I have to ask though, why would one of the most important parts of the coding be forced off on a designer instead of handled by a programmer? Quote Link to comment https://forums.phpfreaks.com/topic/249599-php-multiple-variables-syntax-formatting-help/#findComment-1281450 Share on other sites More sharing options...
shaunmacie Posted October 23, 2011 Author Share Posted October 23, 2011 I'm a print designer that does the occasional website. This one is actually for my wife's business, which has a basic shopping cart and affiliate system that we purchased a few years back. We haven't really done much with the affiliate system until now. I can handle html, javascript, etc fairly well, but thousands of lines of php code is where it starts to get too complicated for my liking. In this case, I figured out how to get the correct code to show the first product purchased, but if they purchase more than one this code will only report the first. For the most part, customers will only be purchasing one product, but you never know. If someone could just provide code that I can place into that spot to report more than just the first data array, I'd be all set. "&ProductID=".$orderInv['0']['productCode']." I don't even need to know how or why it would work, it's nothing I hope to have to do beyond making this function. Quote Link to comment https://forums.phpfreaks.com/topic/249599-php-multiple-variables-syntax-formatting-help/#findComment-1281473 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.