On 3/16/2009 7:17 PM, "Paul M Foster" <paulf@xxxxxxxxxxxxxxxxx> wrote: > Well, I was dubious about my answer, based on the idea that someone else > might have a better way. However, it appears not. > > So what I would do is probably, instead of echoing stuff immediately, > I'd just append it to a string until you're ready to output a total > line. Then output the total line, and immediately after, output the > string you accumulated while counting. Make sense? The whole point in > the first place, as I recall, was to avoid umpteen database queries. So > what you're doing is to load it all up at once and then let PHP do the > heavy work instead of the database. But the total you want is only > available after you've processed all the records for that item/model. So > if you want it to come first on screen, you'll have to "accumulate" all > your detail lines as you go. Then when the total is ready, output that > and then output all the stuff you've accumulated. I don't know any > better way to do it. > > If it's still not clear, let me know. Thanks for your help PAUL - with your explanation I got it working - Yipee!! Like this .... ========================================== $product = ''; $productlast = ''; $show=''; $count = 1; while ($a = mysql_fetch_assoc($getall)) { if ($product != $a['model']) { if ($productlast != '') { echo '<br/><br/><br/>MODEL: '.$productlast.' TOTAL COUNT '.$count.' <br/><br/> '.$show;} $show=''; $count = 1; // resets count for each new model $product = $a['model']; $show = $show . $a['model'].' '.$a['id'].' - loc: '.$a['condition'].' 1<br/>'; } else { $count++; $productlast = $a['model']; $show = $show . $a['model'].' '.$a['id'].' - loc '.$a[' condition'].' 2 <br/>'; } } ==================================== -- Thanks - RevDave Cool @ hosting4days . com [db-lists 09] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php