How do I iterate with a array
that I bring from the database in php and then send all those data obtained by a JSON
to my view?
This is what I have so far:
$conn = new mysqli($host, $user, $pass, $db);
$errores = array();
if ($conn->connect_error) {
echo 'false';
}else{
$razas = $conn->query("SELECT * FROM razas ORDER BY nombre ASC");
if ($razas->num_rows > 0) {
$datos = $razas->fetch_assoc();
$longitud = count($datos);
}
}
What I want to do is go through the array that brings two fields from the database ... Let's bring everything from the table and pass it by JSON
to the view and convert them into <option>
tag for a selector .