encontre este codigo que me muestra los productos que se encuentran alojados en una bd mysql, la pagina y el codigo funciona bien, lo que sucede es que nunca muestra en pantalla el item No 7
me explico: hay 24 articulos, en cada pagina me muestra 6 productos, pero en la siguiente pagina empieza a mostrar desde el numero 8 (8,9,19,11,12,13,14)no muestra el item 7
Código PHP:
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Area Cliente - Productos</title>
<script type="text/javascript" src="js/jquery.js"></script>
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/whmcs.css" rel="stylesheet">
<script src="js/whmcs.js"></script>
</head>
<body>
<div id="whmcsheader">
<div class="whmcscontainer">
<div id="whmcstxtlogo"><a href="">hostingmio.com</a></div>
<div id="whmcsimglogo" align="center"><img src="image/whmcslogo.png" width="253" height="60" /></div>
</div>
</div>
<div class="topbar">
<div class="fill">
<div class="whmcscontainer">
<ul>
<li><a href="administrador.php">Regresar</a></li>
</ul>
<ul class="nav secondary-nav">
<li class="menu">
</li>
</ul>
</div>
</div>
</div>
<div class="whmcscontainer">
<div class="contentpadded">
<div class="page-header">
<div class="styled_title">
<h1>Area Clientes - Productos</h1>
</div>
</div>
<?php
if(!empty($_GET['page'])){
$pag=$_GET['page'];
}else{
$pag=1;
}
$psql=0;
if($pag==1){
$psql=0;
}else{
for($i = 2; $i <=$pag; $i++){
$psql=$psql+6;
}
$psql=$psql+1;
}
$x=1;
$cod1=array(); $nom1=array(); $des1=array(); $est1=array();
include('php_conexion.php');
$csql="SELECT * FROM productos LIMIT $psql , 6";
$can=mysql_query($csql);
while($dato=mysql_fetch_array($can)){
$cod1[$x]=$dato['id'];
$nom1[$x]=$dato['nom'];
$des1[$x]=$dato['des'];
if($dato['estado']=="s"){
$est1[$x]="Disponible"; $clase[$x]="label active";
}else{
$est1[$x]="No Disponible"; $clase[$x]="label unpaid";
}
$x=$x+1;
}
?>
<br />
<div align="right">
<?php
$cans=mysql_query("SELECT COUNT(id) AS numero FROM productos");
if($dat=mysql_fetch_array($cans)){
$numero=$dat['numero']/6;
$numero=(int)$numero;
}
$siguiente=$pag+1; $antes=$pag-1;
if($antes==0){ $antes=1; }
if($siguiente>=$numero){ $siguiente=$numero; }
echo '<p>Pagina Actual [ '.$pag.' ] [ <a href="cliente_producto.php?page='.$antes.'"> << Antes </a>| ';
for($i = 1; $i <=$numero; $i++){
echo '<a href="cliente_producto.php?page='.$i.'">'.$i.'</a> | ';
}
echo ' <a href="cliente_producto.php?page='.$siguiente.'"> Siguiente >> </a> ]</p>';
?>
</div><br />
<table class="zebra-striped">
<thead>
<tr>
<th width="33%" class="headerSortdesc"><p align="center"><?php if(!empty($nom1[1])){ echo $nom1[1]; }?></p></th>
<th width="34%" class="headerSortdesc"><p align="center"><?php if(!empty($nom1[1])){ echo $nom1[2]; }?></p></th>
<th width="33%" class="headerSortdesc"><p align="center"><?php if(!empty($nom1[1])){ echo $nom1[3]; }?></p></th>
</tr>
</thead>
<tr>
<td>
<?php if(!empty($cod1[1])){
echo' <a href="cliente_detalles2.php?codigo='.$cod1[1].'">';
if (file_exists("foto/".$cod1[1].".jpg")){
echo '<div align="center"><img src="foto/'.$cod1[1].'.jpg" width="160" height="160" alt=""></div>';
}else{
echo '<div align="center"><img src="foto/defecto.png" width="160" height="160" alt=""></div>';
}
}
echo '</a>'; ?></td>
<td><?php if(!empty($cod1[2])){
echo' <a href="cliente_detalles2.php?codigo='.$cod1[2].'">';
if (file_exists("foto/".$cod1[2].".jpg")){
echo '<div align="center"><img src="foto/'.$cod1[2].'.jpg" width="160" height="160" alt=""></div>';
}else{
echo '<div align="center"><img src="foto/defecto.png" width="160" height="160" alt=""></div>';
}
} echo '</a>';?></td>
<td><?php if(!empty($cod1[3])){
echo' <a href="cliente_detalles2.php?codigo='.$cod1[3].'">';
if (file_exists("foto/".$cod1[3].".jpg")){
echo '<div align="center"><img src="foto/'.$cod1[3].'.jpg" width="160" height="160" alt=""></div>';
}else{
echo '<div align="center"><img src="foto/defecto.png" width="160" height="160" alt=""></div>';
}
}echo'</a>'; ?></td>
</tr>
<tr>
<td><p align="center"><?php if(!empty($des1[1])){ echo $des1[1]; }?></p></td>
<td><p align="center"><?php if(!empty($des1[2])){ echo $des1[2]; }?></p></td>
<td><p align="center"><?php if(!empty($des1[3])){ echo $des1[3]; }?></p></td>
</tr>
<tr>
<td><p align="center"><span class="<?php if(!empty($clase[1])){ echo $clase[1]; }?>">
<?php if(!empty($est1[1])){ echo $est1[1]; }?></span></p></td>
<td><p align="center"><span class="<?php if(!empty($clase[2])){ echo $clase[2]; }?>">
<?php if(!empty($est1[2])){ echo $est1[2]; }?></span></p></td>
<td><p align="center"><span class="<?php if(!empty($clase[3])){ echo $clase[3]; }?>">
<?php if(!empty($est1[3])){ echo $est1[3]; }?></span></p></td>
</tr>
<thead>
<tr>
<th width="33%" class="headerSortdesc"><p align="center"><?php if(!empty($nom1[4])){ echo $nom1[4]; }?></p></th>
<th width="34%" class="headerSortdesc"><p align="center"><?php if(!empty($nom1[5])){ echo $nom1[5]; }?></p></th>
<th width="33%" class="headerSortdesc"><p align="center"><?php if(!empty($nom1[6])){ echo $nom1[6]; }?></p></th>
</tr>
</thead>
<tr>
<td>
<?php if(!empty($cod1[4])){
echo' <a href="cliente_detalles2.php?codigo='.$cod1[4].'">';
if (file_exists("foto/".$cod1[4].".jpg")){
echo '<div align="center"><img src="foto/'.$cod1[4].'.jpg" width="160" height="160" alt=""></div>';
}else{
echo '<div align="center"><img src="foto/defecto.png" width="160" height="160" alt=""></div>';
}
}echo '</a>'; ?>
</td>
<td>
<?php if(!empty($cod1[5])){
echo' <a href="cliente_detalles2.php?codigo='.$cod1[5].'">';
if (file_exists("foto/".$cod1[5].".jpg")){
echo '<div align="center"><img src="foto/'.$cod1[5].'.jpg" width="160" height="160" alt=""></div>';
}else{
echo '<div align="center"><img src="foto/defecto.png" width="160" height="160" alt=""></div>';
}
} echo '</a>'; ?>
</td>
<td><?php if(!empty($cod1[6])){
echo' <a href="cliente_detalles2.php?codigo='.$cod1[6].'">';
if (file_exists("foto/".$cod1[6].".jpg")){
echo '<div align="center"><img src="foto/'.$cod1[6].'.jpg" width="160" height="160" alt=""></div>';
}else{
echo '<div align="center"><img src="foto/defecto.png" width="160" height="160" alt=""></div>';
}
} echo '</a>'; ?></td>
</tr>
<tr>
<th><p align="center"><?php if(!empty($des1[4])){ echo $des1[4]; } ?></th>
<th><p align="center"><?php if(!empty($des1[5])){ echo $des1[5]; } ?></th>
<th><p align="center"><?php if(!empty($des1[6])){ echo $des1[6]; } ?></th>
</tr>
<tr>
<td><p align="center"><span class="<?php if(!empty($clase[4])){ echo $clase[4]; }?>">
<?php if(!empty($est1[4])){ echo $est1[4]; }?></span></p></td>
<td><p align="center"><span class="<?php if(!empty($clase[5])){ echo $clase[5]; }?>">
<?php if(!empty($est1[5])){ echo $est1[5]; }?></span></p></td>
<td><p align="center"><span class="<?php if(!empty($clase[6])){ echo $clase[6]; }?>">
<?php if(!empty($est1[6])){ echo $est1[6]; }?></span></p></td>
</tr>
</table>
<div align="right">
<?php
$cans=mysql_query("SELECT COUNT(id) AS numero FROM productos");
if($dat=mysql_fetch_array($cans)){
$numero=$dat['numero']/6;
$numero=(int)$numero;
}
$siguiente=$pag+1; $antes=$pag-1;
if($antes==0){ $antes=1; }
if($siguiente>=$numero){ $siguiente=$numero; }
echo '<p>Pagina Actual [ '.$pag.' ] [ <a href="cliente_producto.php?page='.$antes.'"> << Antes </a>| ';
for($i = 1; $i <=$numero; $i++){
echo '<a href="cliente_producto.php?page='.$i.'">'.$i.'</a> | ';
}
echo ' <a href="cliente_producto.php?page='.$siguiente.'"> Siguiente >> </a> ]</p>';
?>
</div>
</div>
</div>
</div>
<div class="footerdivider">
<div class="fill"></div>
</div>
<div class="whmcscontainer">
<div class="footer">
<?php
$sqll=mysql_query("SELECT * FROM empresa WHERE id=1");
if($dato=mysql_fetch_array($sqll)){
$web=$dato['nombre'];
}
?>
<div id="copyright" align="center"><?php echo $web; ?> - Copyright © 2012.</div>
<div class="clear"></div>
</div>
</body>
</html>