How can I get hold of Bank ID to load in HTML select
My function like this:
public function ComboBox($sql, $idcampo, $selected)
{
$cn = conexao::getInstance()->prepare($sql);
echo "<select name='" . $idcampo . "'>";
$selec = "";
while ($row = $cn->fetch(PDO::FETCH_ASSOC)) {
if ($row[1] == $selected) {
$selec = " selected";
} else {
$selec = "";
}
echo "<option value='" . $row[1] . "'" . $selec . ">" . $row[2] . "</option>";
}
echo "</select>";
}
When calling the function and passing $ sql, $ idcampo and status (selected or not).
I call it to generate the select to select the value to do the insertion, I just do not know how to get the $ field from the insert page, because it would need to load all $ id's from the database to populate the select in HTML.
In call: <?php echo $objct->ComboBox('select id, nome from cliente', $objcli->getIdcli(), 0); ?>