gracias jerkan,
he probado tu codigo y me da error. te pongo como queda en mi aplicacion, ya que como lo he implementado, quizas haga algo mal:
Código:
$where = array();
if( $provincia != 0 )
{
$where[] = "provincia='$provincia'";
}
if( $categoria != 0 )
{
$where[] = "categoria ='$categoria'";
}
if( !empty($where) )
{
$where_sql = implode(' AND ', $where);
}
$sql1 = "SELECT * FROM datos_ofertas $where_sql";
$registros = mysql_query($sql1);
//Primera parte de la paginación
$total_regs=mysql_num_rows($registros);
$por_pag=20;
$total_pags=ceil($total_regs/$por_pag);
if(isset($pag))
{
$inicio=($pag-1)*$por_pag;
}
else
{
$inicio="0";
$pag="1";
}
$sql= "SELECT * FROM datos_ofertas $where_sql ORDER BY fecha DESC LIMIT ".$inicio.",".$por_pag;
$resultados = mysql_query($sql);
que hago mal?
no acabo de entender tu programacion
creo que la consulta siempre me devuelve los mismos datos...