$tam_pag = 6;
if($pag!=""){$pagina=$pag;}else{$pagina=1;}
$sql="select * from productos where habilitado = 1 order by nombre desc, id";
$rs=mysqli_query($conexion,$sql);
if(mysqli_num_rows($rs)){$tot_pag=mysqli_num_rows($rs);}
$cantidad = ceil($tot_pag / $tam_pag);
$paginador = ($pagina-1) * $tam_pag;
$rs=mysqli_query($conexion,$sql." limit $paginador, $tam_pag");
?>
if($pagina!=1){?>

}?>
while ($row=mysqli_fetch_assoc($rs)) {?>
}?>
if($cantidad>$pagina){?>

}?>