Ver Mensaje Individual
  #5 (permalink)  
Antiguo 03/02/2011, 05:54
angeles33
 
Fecha de Ingreso: noviembre-2007
Mensajes: 122
Antigüedad: 16 años, 4 meses
Puntos: 2
Respuesta: no mostrar un registo en un listado

ahi te dejo el codigo

function Consultar ( $tabla, $campos = "*", $condicion = "1", $orden = "id", $mostrar = false ) {
if ($condicion=='true') $condicion = '1';
if ( $condicion )
$sql = 'Select '.$campos.' From '.$tabla.' Where '.$condicion.' Order By '.$orden.'';
else
$sql = 'Select '.$campos.' From '.$tabla.' Order By '.$orden.'';

$this -> sql = $sql; // Copio la cadena sql a la propiedad de la clase para almacenarla

if( $mostrar ) echo '<br>Consulta SQL: '.$sql.'<br>';

$this -> result = @mysql_query ( $sql, $this->conexion );

if ( $this -> result ) {
$this -> row = @mysql_fetch_array ( $this -> result );
$this -> num = @mysql_num_rows ( $this -> result );
return true;
} else {
//$this -> Alert("HA HABIDO UN ERROR EN LA CONSULTA.");
echo "<br>**ERROR[".$this->database."][".$_SERVER['PHP_SELF']."]: Consulta SQL: $sql <br>";
//$exito = $this -> correo -> NotificarError ("**ERROR: [".$this->user."] [".$this->database."][".$_SERVER['REQUEST_URI']."]: Consulta SQL: ".$sql,$this->destinoError);
return false;
}

}
---------------

$sql = new Conectar ();

if ($_GET['p']==1) {
$cond = 'activo=1';
}

if ($_GET['p']==2) {
$cond = 'activo=0';
}

if (!$_GET['p']) {
$cond = 'true';
}

$sql -> Consultar ('noticias','*',$cond,'fecha desc');

$num_total_registros = $sql->num;
$total_paginas = ceil($num_total_registros / $TAMANO_PAGINA);

$sql -> Consultar ('noticias','*',$cond,'fecha desc limit ' . $inicio . ',' . $TAMANO_PAGINA);