I already asked a question belonging this issue here
The code from the accepted answer by RiggsFolly works really proper but there is a small issue with that. I needed some days to test it out and searched for the reason why this is not the best way to solve the main goal. I was pleased to open a new question.
The code from RiggsFolly is based on $current_provider so the while-loop checks on every round if $current_provider has changed. So far so good. BUT now I needed to add a comprehensive logic. It meens that I added a true/false variable that simply checks if a value from an fetched object is equal to a certain string. This comparison is focused on a specific list item and not to the basic $current_provider.
So the goal is that $current_provider checks each fetched object for true/false and will be independent from $current_provider. At the moment I try to extend with a second loop but just want to give an example in the hope that it will be clear what to achieve:
$service = $db->query("SELECT * FROM `system` ORDER BY provider, artist");
$provider = NULL;
$close = false;
while ($data = $service->fetch_object()) {
$amount_1 = $data->digit_1; //db-structure: float
$amount_2 = $data->digit_2; //db-structure: float
if ($amount_1 == $amount_2) {
$close = true;
}
if ( $current_provider != $data->provider ) {
if ( $current_provider !== NULL ) {
echo '</div>close container in case of current_provider is already set';
}
echo '<div class="provider">open a new container in case of current_provider is not like data->provider or empty';
$current_provider = $data->provider;
}
echo 'some styling for each object';
if ($close === true ) {
echo '<div class="specific">if the amount_1 is same like amount_2 for a single object add only for this object a certain div';
} else {
echo '<div>show standard container even on specific object';
}
echo '</div><!--close container provider-->';
}
Kind regards.
if ($something === $another) {as neither of these variables are used in you sample codedigit_1 == digit_2but the second isn't but it also adds the specific container on all other elements wihtin the provider even the second and third element what is even not true.