I need to compare between two tables the values saved in the bank and bring in an option the results (tb_carteras and tb_carteirasclientes), if more than one record should be inserted the selected.
In the tb_carriers table I have 10 records with id and name In the table tb_charteirasclientes I have 2 records with id and wallet
I need to select it to select the selected="selected" when id.tb_carteras and walteira.tb_carteirasclientes are equal
In the script below only happens in the first comparison record and does not pass to the second.
<select class="selectpicker" data-style="select-with-transition" multiple title="Selecione a Carteira:<code>*</code>" required="true" aria-required="true" aria-invalid="true" title="Carteira" name="carteira[]" id="carteira">
<?php
$readSes = new Read;
$readSes->FullRead("
SELECT
tb_carteiras.nome,
tb_carteiras.id,
tb_carteirasclientes.carteira
FROM 'tb_carteiras'
LEFT JOIN 'tb_carteirasclientes'
ON 'tb_carteirasclientes'.carteira = 'tb_carteiras'.id
ORDER BY
tb_carteiras.id ASC
");
if (!$readSes->getResult()):
echo '<option disabled="disabled" value="null"> Nenhuma Carteira cadastrado. </option>';
else:
foreach ($readSes->getResult() as $ses):
echo "<option value=\"{$ses['id']}\" ";
if ($ses['id'] == $ClienteData['carteira']):
echo ' selected="selected" ';
endif;
echo "> {$ses['nome']} </option>";
endforeach;
endif;
?>
</select>