Foros del Web » Programando para Internet » PHP »

[SOLUCIONADO] Resource id #3 EN UN COUNT DE TABLA?

Estas en el tema de Resource id #3 EN UN COUNT DE TABLA? en el foro de PHP en Foros del Web. PORQUE ME APARECE EL Resource id #3 CUANDO TRAIGO UN VALOR DE UNA CONSULTA...... NO ES UN CAMPO DE LA TABLA SINO UN COUNT DE ...
  #1 (permalink)  
Antiguo 02/04/2013, 16:14
Avatar de skardo  
Fecha de Ingreso: febrero-2013
Ubicación: Lima
Mensajes: 68
Antigüedad: 11 años, 2 meses
Puntos: 1
Pregunta Resource id #3 EN UN COUNT DE TABLA?

PORQUE ME APARECE EL Resource id #3 CUANDO TRAIGO UN VALOR DE UNA CONSULTA...... NO ES UN CAMPO DE LA TABLA SINO UN COUNT DE FILAS DE LA TABLA, COMO DEBO IMPRIMIRLA?

Código PHP:
Ver original
  1. <?php
  2.     $servicio1=mysql_query("SELECT count(imagen_id) FROM imagen where estado='1'");
  3.     $result = mysql_query($servicio1);
  4.     $servicio2=mysql_query("SELECT * FROM imagen where estado=1 order by imagen_id DESC Limit 1;");
  5.     ?>
  6.     <td class="index_row_info">
  7.      Total: <?php echo $result; ?></br>Ultimo Registro: <?php echo $servicio2; ?>

ME SALE ESTO:
Total: Resource id #2
Ultimo Registro: Resource id #3

CUANDO QUIERO QUE ME SALGA ESTO
Total: 28
Ultimo Registro: 34

AYUDENME
  #2 (permalink)  
Antiguo 02/04/2013, 16:26
 
Fecha de Ingreso: abril-2008
Ubicación: El Salvador
Mensajes: 736
Antigüedad: 16 años
Puntos: 47
Respuesta: Resource id #3 EN UN COUNT DE TABLA?

Mira lee un poco para que comprendas el funcionamiento....


Código PHP:
Ver original
  1. <?php
  2.     $servicio1=mysql_query("SELECT count(imagen_id) cantidad FROM imagen where estado='1'");
  3.     $result = mysql_query($servicio1);
  4.     $total=mysql_fetch_array($result);
  5.    
  6.     //Si lo que queres hacer es sacar el ultimo id de imagen que has generado podes hacerlo asi
  7.     $servicio2=mysql_query("SELECT max(id_imagen) id FROM imagen where estado=1 order by imagen_id DESC Limit 1;");
  8.     $ultimoId=mysql_fetch_array($servicio2);
  9.     ?>
  10.     <td class="index_row_info">
  11.      Total: <?php echo $total["cantidad"]; ?></br>Ultimo Registro: <?php echo $ultimoId["id"]; ?>
  #3 (permalink)  
Antiguo 02/04/2013, 17:02
Avatar de skardo  
Fecha de Ingreso: febrero-2013
Ubicación: Lima
Mensajes: 68
Antigüedad: 11 años, 2 meses
Puntos: 1
Respuesta: Resource id #3 EN UN COUNT DE TABLA?

lo probe y no da, podrias explicarme como funciona?
  #4 (permalink)  
Antiguo 02/04/2013, 17:10
Avatar de andresdzphp
Colaborador
 
Fecha de Ingreso: julio-2011
Ubicación: $this->Colombia;
Mensajes: 2.749
Antigüedad: 12 años, 9 meses
Puntos: 793
Respuesta: Resource id #3 EN UN COUNT DE TABLA?

No cuesta nada leer el manual:

http://www.php.net/manual/es/functio...-fetch-row.php

http://www.php.net/manual/es/functio...etch-array.php
__________________
Si sabemos como leer e interpretar el manual será mucho más fácil aprender PHP. En lugar de confiar en ejemplos o copiar y pegar - PHP

Etiquetas: count, mysql, registro, resource, select, sql, tabla
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:51.