Ver Mensaje Individual
  #2 (permalink)  
Antiguo 13/05/2012, 19:05
Avatar de gjx2
gjx2
 
Fecha de Ingreso: agosto-2008
Ubicación: R.D
Mensajes: 1.153
Antigüedad: 15 años, 8 meses
Puntos: 139
Respuesta: Listar datos de bd dentro de array

Intenta de esta manera

Código PHP:
Ver original
  1. include('conexion.php');
  2. $consulta = "Select * from recetas WHERE ORDER by id DESC";
  3. $resultado = mysql_query($consulta);
  4. $cant = mysql_num_rows($resultado); //Cuento la cantidad de registros
  5.    
  6.  
  7.     while($fila = mysql_fetch_array($resultado))
  8.     {
  9.        
  10.         $recetas[] = array(
  11.             "categoria" => $fila['categoria'],
  12.             "titulo" => $fila['titulo'],
  13.             "porciones" => $fila['porciones'],
  14.             "ingredientes" => $fila['ingredientes'],
  15.             "elaboracion" => $fila['elaboracion'],
  16.             "foto" => $fila['foto'],
  17.             "fuente" => $fila['fuente'],
  18.         );
  19.     }
  20.  
  21.  
  22. echo json_encode($recetas);

Saludos.