Ok I understand your method now. your code does not match your output. how
would your print line produce that , $customerid ?

anyways...

$data = orders($id,$status);
$c = count($data);
$currentId;
$n = 1;
for($i=0; $i<$c; $i++) {
   $orderid = $data[$i]['orderid'];
   $customerid = $data[$i]['customerid'];
   $name = $data[$i]['name'];
   if($currentid == $customerid) {
        //Continue current customer group
        print $orderid.' - '.$customerid.' - '.$name.'<br>';
   } else {
        //Begin a new group...
        $currentId = $customerid;
        Print("Customer ".$n");
        $n++;
   }
}

I'm kind of headed out so its a bit rushed and the example above wont work
as given but you get the idea from the two comments I added...
On 7/11/06, Dallas Cahker <[EMAIL PROTECTED]> wrote:

I have an array that i would like to sort and reorder based on a simple
critera.  I already order the data but I would like to break the data now
into sections by customer id, so one customer has 5 things and another
customer has one.  How can I do that with an array.

$data = orders($id,$status);
$c = count($data);

for($i=0; $i<$c; $i++) {
$orderid = $data[$i]['orderid'];
$customerid = $data[$i]['customerid'];
$name = $data[$i]['name'];
print $orderid.' - '.$customerid.' - '.$name.'<br>';
}

What it is currently is all the orders are ordered by the customer number,
however I would like to group it a little nicer on the output.

Current:
1234 - blah blah blah - Y - 3, 01234
1235 - blah blah blah - N - 6, 01234
1236 - blah blah blah - N - 6, 01234
1237 - blah blah blah - Y - 6, 11256
1238 - blah blah blah - N - 6, 22589
1239 - blah blah blah - N - 6, 22589
1240 - blah blah blah - Y - 6, 22589
1241 - blah blah blah - N - 6, 22589

Would like:
01234 - The Customer 1
1234 - blah blah blah - Y - 3
1235 - blah blah blah - N - 6
1236 - blah blah blah - N - 6

11256 - The Customer 2
1237 - blah blah blah - Y - 6

22589 - The Customer 3
1238 - blah blah blah - N - 6
1239 - blah blah blah - N - 6
1240 - blah blah blah - Y - 6
1241 - blah blah blah - N - 6

Anyway I can do that?


Reply via email to