Ver Mensaje Individual
  #5 (permalink)  
Antiguo 12/06/2008, 11:59
Avatar de GatorV
GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Respuesta: Crear una Funcion para Consultas

Prueba así:
Código PHP:
function consulta($sql) { 
    
$query=mysql_query($sql); 
    
$cantidad mysql_num_rows($query); 
    if (
$cantidad 0) { 
        echo 
"<table>"
        while (
$array=mysql_fetch_row($query)) { 
            foreach(
$array as $campo ) {
                        echo 
"<tr><td></td><td>".$campo." </td></tr>"
                 }
            } 
            echo 
"</table>"
        } else {
        echo 
"No se encontraron registros"
        } 

Saludos.