shaiss Posted August 3, 2009 Share Posted August 3, 2009 I can't figure out why this snippet of code isn't working any ideas? $productref = $order_detail[$i][2]; //#2 is the product ID $orderqty = $order_detail[$i][3]; //#3 is the SKU # The Array: $order_detail array 0 array id_order_detail string = 1 product_id string = 7 product_qtantity string = 1 reference string = 1021400 This array is the result of a mysql query. Any help is appriciated. Thank you!!!!! Here is the entire function if needed function BuildQueryString($order_id, $order_detail) { $num = sizeof($order_detail); $i=0; $count=1; $baseURL = "OrderNumber=$order_id"; while ($i < $num) { $productref = $order_detail[$i][2]; //#2 is the product ID $orderqty = $order_detail[$i][3]; //#3 is the SKU # /*$productref = "&SKU0$count=$productref&"; $orderqty = "Qty0$count=$orderqty";*/ $sku = "&SKU0$count=$productref&"; $qty = "Qty0$count=$orderqty"; $prodURL = $prodURL . $sku . $qty; $i++; $count++; } return $baseURL . $prodURL; } Link to comment https://forums.phpfreaks.com/topic/168676-walking-through-a-multi-demnsional-php-array/ Share on other sites More sharing options...
TeNDoLLA Posted August 3, 2009 Share Posted August 3, 2009 Should not it be like this, would seem like you are using associatve arrays from mysql result ? <?php $productref = $order_detail[$i]['product_id']; // is the product ID $orderqty = $order_detail[$i]['product_quantity']; // is the SKU # Link to comment https://forums.phpfreaks.com/topic/168676-walking-through-a-multi-demnsional-php-array/#findComment-889837 Share on other sites More sharing options...
shaiss Posted August 3, 2009 Author Share Posted August 3, 2009 Should not it be like this, would seem like you are using associatve arrays from mysql result ? <?php $productref = $order_detail[$i]['product_id']; // is the product ID $orderqty = $order_detail[$i]['product_quantity']; // is the SKU # Thanks for the help! that worked. Didn't know I couldn't use columns. Link to comment https://forums.phpfreaks.com/topic/168676-walking-through-a-multi-demnsional-php-array/#findComment-889845 Share on other sites More sharing options...
shaiss Posted August 3, 2009 Author Share Posted August 3, 2009 Because I used mysql associative array this is the correct code: <?php $productref = $order_detail[$i]['product_id']; // is the product ID $orderqty = $order_detail[$i]['product_quantity']; // is the SKU # Link to comment https://forums.phpfreaks.com/topic/168676-walking-through-a-multi-demnsional-php-array/#findComment-889849 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.