Good afternoon, guys! I'm starting in PHP and I already had a problem. It is as follows:
I need to go through all records in the bank table so that I can validate if that value already exists. I'm using Codeigniter and did the following plus or minus this:
$sql = $this->db->query("SELECT * FROM tabela")->result;
foreach ($sql as $resultado) {
if ($resultado->valor == $this->input->post("valor")) {
echo "Valor já existente";
} else {
echo "Cadastro OK";
}
}
In this way you are only validating the first record of the table, that is, it only takes the "value" of the first row and shows "Value already existing". Home But if the value sought is from the second record, it continues to register. Home Thank you in advance!