On 3/14/2009 9:31 PM, "Paul M Foster" <paulf@xxxxxxxxxxxxxxxxx> wrote: > > I'm not an expert, but the way I normally do something like this is with > a join that would give name, model and condition on each row (so you > have a lot of duplicate fields which are the same for a series of > records). I make sure they're ordered properly, and then process them in > a loop. Something like: > > $product = ''; > $count = 0; > while ($a = fetch_array()) { > if ($product != $a['name']) { > // do whatever for prior product > // do whatever for new product > // $count will be the number of a given product > $product = $a['name']; > } > else { > $count++; > // print out whatever you need to > } > } Hi Paul - I appreciate your assistance, $product = ''; $count = 1; while ($a = mysql_fetch_assoc($getall)) { if ($product != $a['model']) { echo '<br/> COUNT: '.$count.' final previous'.'<br/><br/>'; $count = 1; // resets count for each new model echo ' model: '.$a['model'].'<br/><br/>'; // model title line echo $a['id'].' - condition: '.$a['loc'].' 1<br/>'; // start detail row list $product = $a['model']; } else { $count++; echo $a['id'].' - condition: '.$a['condition'].' 2 <br/>'; } } ------------------------------ Produces something like: COUNT: 39 (final previous) model: MODEL 22-A 34 - condition: good 33 - new 32 - old 305 - new Etc... ------------------------ Paul - this seems to work (if I understand you correctly...), but I would like to have a title line (above) say: MODEL - 22-A - COUNT: 39 At the top ... Currently - the way I have it wants to display the *count BELOW* the line items - (when it's done counting) .. And I fooled with this line; echo '<br/> COUNT: '.$count.' final previous'.'<br/><br/>'; Which 'sort of' shows at top - but doesn't really help the 1st item... Q: any way to improve this? -- 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