";
//echo "off->" .$offset ." lim-> ".$limit;
if ($offset>1) { // bypass PREV link if offset is 0
$prevoffset=$offset-$limit;
print "<< \n";
}
// calculate number of pages needing links
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so add one page
$pages++;
}
for ($i=1;$i<=$pages;$i++) { // loop thru
$newoffset=$limit*($i-1);
print "$i | \n";
}
// check to see if last page
if (!(($offset/$limit)==$pages) && $pages!=1) {
// not last page so give NEXT link
$newoffset=$offset+$limit;
print ">>\n";
}
print "
";
}
function OpcionesQuery() {
Global $Categoria;
$rsCategoria = mysql_query("Select categorias_ID, categorias_descripcion from categorias order by categorias_descripcion");
CampoComboRsGenera("Categoria","Líneas de Artículos ",$rsCategoria,$Categoria,'categorias_ID','categorias_descripcion',true,false,1);
QueryGenera();
}
function MuestraRegistro($reg,$el_i) {
global $select;
if (($el_i % 2 ) == '0')
$colorfila = "#eeeeee";
else
$colorfila = "#ffffff";
FilaInicio($colorfila);
DatoGenera($reg["item_descrip"]);
DatoGenera($reg["item_atrib1"],"Dato","center");
DatoGenera($reg["item_precio"],"Dato","right");
FilaFinal();
}
//------------------
// CUERPO PRINCIPAL
//------------------
if (!isset($orden) | empty($orden) )
$orden = "item_codigo ";
$where = " item_ID > '0' ";
if (isset($query) | isset($Categoria))
{
if ($Categoria <> '0')
$where .= " and (item_categoria = '".$Categoria."')";
} else
$where .= " and (item_categoria <> '0')";
//-- Preparo informacion - recorset segun condiciones recibidas --
$limit = 100;
$sql = "select * from items where ".$where ;
$numresults=mysql_query($sql);
$numrows=mysql_num_rows($numresults);
// next determine if offset has been passed to script, if not use 0
if (empty($offset)) {
$offset=0;
}
// preparo nombres de los atributos
$sql = "select * from atrib_items";
$rs = mysql_query($sql);
$aAtrib = array("","","","","");
while ($reg=mysql_fetch_array($rs))
{
// echo $reg["atrib_ID"]. $reg["atrib_nombre"];
$aAtrib[$reg["atrib_ID"]] = $reg["atrib_nombre"];
}
$sql = "select item_ID, item_descrip,item_categoria,item_precio,item_atrib1,item_atrib2,item_atrib3,item_atrib4,item_imagen1,item_detalle,item_codigo from items where ".$where." order by item_categoria limit $offset,$limit ";
$rs = mysql_query($sql);
$titulos = array("Producto","Presentación","Precio \$");
echo "