Good afternoon guys,
I have two data in the database, but making the select only 1 appears, why?
<?php
ini_set('display_errors', true);
error_reporting(E_ALL);
include_once("con.php");
$pdo = conectar();
$opcao = $_GET['opcao'];
switch ($opcao) {
case 'pegaCategoria':
$pegaCategoria=$pdo->prepare("SELECT * FROM categoriaComum");
$pegaCategoria->execute();
$return = array();
while ($linhaCateAdmin=$pegaCategoria->fetch(PDO::FETCH_ASSOC)) {
$idcategoriaComum = $linhaCateAdmin['idcategoriaComum'];
$categoriaComum = $linhaCateAdmin['categoriaComum'];
$return = [
"idcategoriaComum" => $idcategoriaComum,
"categoriaComum" => $categoriaComum
];
}
echo json_encode($return);
break;
?>
And from the image below, you can see that I have two data in the table.
Andintheconsole,only1isdisplayed.