Hi, I have the following problem, I am creating two functions to show queries in json format. This is my code:
<?php
include'db.php';
class Descuento extends Database{
public function listar_producto(){
$sql = "CALL sp_mostrar_producto";
$array = array();
$query = mysqli_query($this->con,$sql);
while($row = mysqli_fetch_array($query)){
$array[] = $row;
}
echo json_encode($array);
}
public function listar_categoria(){
$sql = "SELECT * FROM alm_categoria ";
$array = array();
$query = mysqli_query($this->con,$sql);
while($row = mysqli_fetch_assoc($query)){
$array[] = $row;
}
echo json_encode($array);
}
}
$desc = new Descuento();
if(isset($_GET["show"])){
$respuesta = $_GET["show"];
if($respuesta == 1){
$desc->listar_producto();
}elseif($respuesta == 2){
$desc->listar_categoria();
}
}
?>
The problem is that when I have to show list_product () , it does not show, while list_category () if it does. I also add that when I use the query:
SELECT * FROM glb_producto
in list_product (), if it works Thanks in advance.