1
I am in need of stopping the functioning of a particular chunk of code. Exit, how die, stops the whole foreach code block.
I just need it to stop inside the if, but keep running the foreach, then go back to those ifs, but not running the first if
for example
foreach ($stmt->fetchAll() as $item => $value){
$this->return = '
<div class="form-group">
<div class="col-lg-12">
';
if($value->nome_categoria === 'USERS') {
$this->return .= 'USERS';
$this->achouUsers = true;
while (!$this->achouUsers){
continue;
}
}
if($value->nome_categoria === "OPTIONS"){
$this->return .= 'OPTIONS';
$this->achouUsers = true;
while (!$this->achouOptions){
continue;
}
}
if( $value->nome_categoria === "MFP E CONNECTOR" ){
$this->return .= 'MFP E CONNECTOR';
while (!$this->achouMDF){
continue;
}
}
$this->return .= '
</div>
<div class="col-lg-12">
<div class="col-lg-10">
<input type="radio" name="inputUsuarios">
'.utf8_encode($value->nome_item).'
'.(utf8_encode($value->nome_item) === 'Até' ? '<input type="text" > usuários <button class=" btn btn-warning"><i class="fa fa-calculator"></i> </button>' : '').'
</div>
<div class="col-lg-2 text-right">
'.number_format($value->valor_item,2,',','.').'
</div>
</div>
</div>
';
echo $this->return;
}
ran if from USERS only once. from there ran everything, and continued running, but testing instead of USERS, but OPTIONS instead
EDITION 1
The expected result was something like
Showing the category only once, the USERS on top of this image, the OPTIONS on top of this image and etc. It pulling from the bank but only appearing once.
With this code my return is being something like
This chunk of code is very confusing and doesn’t seem to make sense. What exactly do you need to do? I say this in the sense of what is the intended result (and not in the medium described in the question). What is the expected result?
– Woss
I will edit in the question the idea
– gabrielfalieri
it goes there... the idea, and the return as it is coming
– gabrielfalieri
You always concatenate into
return
the value ofnome_categoria
, then why do theif
?– Woss
the idea would be to stop the execution of USERS, OPTIONS
– gabrielfalieri
Notice that it’s coming USERS, something, USERS something
– gabrielfalieri
Okay, I think I’m starting to understand. All of these options are generated from the loop, right? You want the title to appear
Users
at the beginning and when to change the title you want to appear again, in case,Options
, etc.?– Woss
Yeah, that’s exactly it
– gabrielfalieri