Search code examples
phpmysqlrecords

Error displaying Records in my table: It shows one record less


I'm showing records in a table from my database.

BUT If I have 6 records, my .php file shows me 5... It shows me one record less: I've looking in pages like this, but I still have the error...

Any idea?

This is my code:

    <?php 
    include 'conexion.php';
    $contabla=conexion();
    $sqltabla="select * from precotizacion p, producto pro where p.idproducto=pro.id";
    $resutadotabla=mysql_query($sqltabla,$contabla);
    $dato=mysql_fetch_array($resutadotabla);

$contador=0;
while ($dato=mysql_fetch_array($resutadotabla))
{
    $contador++;
    echo "<td>".$contador."</td>";
    echo "<td>".$dato['id']."</td>";
    echo "<td>".$dato['parte']."</td>";
    echo "<td>".$dato['descripcion']."</td>";
    echo "<td><input size='3' name='pcanitdad' id='idcantidad' value ='1' onchange='editarproducto(this.value)'> </td>";
    echo "<td>".$dato['pfinal']."</td>";
    echo "<td>subtotal</td>";
    echo "<td>Descuento aplicado</td>";
    echo "<td>total";
    echo "<td><select name='desc' id='desc' onchange='descuento(this.value)'>
    <option >Aplicar</option>
    <option >1</option>
    <option >2</option>
    <option >3</option>
    <option >4</option>
    <option >5</option>
    </select></td>";
    echo '<td><a href="abcs/eliminarprecotizacion.php?id='.$dato['id'].'"> Eliminar producto </a></td>';
    echo "</tr>";
}
?> 

Solution

  • Before going into while, please delete this line:

    $dato=mysql_fetch_array($resutadotabla);
    

    That line will get the first records and then it will go into the while loop, and starting with the second one.