I have the function that returns all the registered brands: (With fields ID and BRAND)
public function lista(){
$lista = array();
$n = 0;
$db = new mysql();
$exec = $db->executar("SELECT * FROM automovel_marca order by marca asc");
while($data = $exec->fetch_object()){
$lista[$n]['id'] = $data->id;
$lista[$n]['marca'] = $data->marca;
$n++;
}
return $lista;
}
And the function that returns the models: (With fields ID, IDMARCA and MODEL)
public function lista(){
$lista = array();
$n = 0;
$db = new mysql();
$exec = $db->executar("SELECT * FROM automovel_modelo order by modelo asc");
while($data = $exec->fetch_object()){
$lista[$n]['id'] = $data->id;
$lista[$n]['idmarca'] = $data->idmarca;
$lista[$n]['modelo'] = $data->modelo;
$n++;
}
return $lista;
}
I was able to pull them individually in FORMS, the problem is that I wanted the FORM MODEL field of the FORM to be related to the MARK field, when the person selects the mark it displays all the models referring to that mark.
The DB structure looks like this:
automovel_marca (id, brand) automovel_modelo (id, idmarca, modelo) - in this case the idmarca follows the relation of the automovel_marca id