Display Block of Code for Each Record in Database

Hello,

I am attempting to display a set of links based off of information from my database.
However, my current attempts cause some issues.

You see, I am using the while statement to display a simple <a href=“”></a> followed by two new lines per each record in the table.
However, this causes two new lines at the end of the page, even though I have no use for it for the last record.

Is there any way to display things for each record, and a different one for the last record?
I don’t want extra spacing if nothing follows the last record.

Thanks,
Eric

Put something after every record except the last = put something before each record except the first. Using that logic, you can use something like


$first=true;
foreach($record as $rec) {
   if (!$first) echo '<br /><br />';
   // do something with $rec
   $first=false;
}

:slight_smile:

Thanks.