Welcome Guest, Not a member yet? Register   Sign In
Basic Report output i can't get my head around
#6

[eluser]mddd[/eluser]
I think it's not so hard. Just a bit of logical thinking.
If I get you right, you need to show the 'closing' div after each location? Well, how do you know it's the last one? You could look at the next one coming up. Like so:
Code:
// show the info
$currentlocation = '';
foreach ($list as $index=>$item)     // --- added $index to keep track of the keys AND values
{
   // show location title if coming into a new location
   if ($item['locationtitle']!=$currentlocation)
   {
      echo '<p><b>'.$item['locationtitle'].'</b></p>';
      $currentlocation=$item['locationtitle'];
   }
   // show item
   echo '<p>'.$item['name'].'</p>';

   // was this the last one?
   // that's the case if the locationtitle for the next item in line is different.
   // OR if there is no next item in line (so this is the very last one)
   if (!isset($list[($index+1)]) || $list[($index+1)]['locationtitle'] != $item['locationtitle'])
   {
      // show your ending div here
   }
}
See? Not too difficult if you take a logical approach.


Messages In This Thread
Basic Report output i can't get my head around - by El Forum - 07-22-2010, 04:30 AM
Basic Report output i can't get my head around - by El Forum - 07-22-2010, 05:24 AM
Basic Report output i can't get my head around - by El Forum - 07-22-2010, 07:55 AM
Basic Report output i can't get my head around - by El Forum - 07-22-2010, 09:42 AM
Basic Report output i can't get my head around - by El Forum - 07-23-2010, 12:45 AM
Basic Report output i can't get my head around - by El Forum - 07-23-2010, 12:54 AM



Theme © iAndrew 2016 - Forum software by © MyBB