Jump to content

Walking Through a Multi-Demnsional PHP Array


shaiss

Recommended Posts

I can't figure out why this snippet of code isn't working  :facewall: 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;
}

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 #

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.