php_mysql_assoc ignores first record.
Hi there I'm trying to query my database to get all the records that share the same "ITEMID" the table is a transaction list of operations done on items in the database.

I've checked the SQL query in phpmyadmin and it works correctly but when I run the php code it ignores the first record every time. Here's my code 
    
    <?php 
     // Get the quantity of each item 
     $sql1 = 'SELECT  `IDPENTERED` ,  `ITEMID` ,  `QTY` ,  `VALUE` FROM  `tblpieceentered` 
      WHERE  `ITEMID` =307 ' ;

     echo $sql1."<br>";

     // Retrieve all the data from the table
     $result1 = mysql_query($sql1)
     or die(mysql_error()); 

     // store the record of the table into $row1
     $row1 = mysql_fetch_array( $result1 ); 
 
     $i = 1; 
     $num = mysql_num_rows ($result1);
 
     echo "Num rows: $num <br>"; 
 
     while ($row1 = mysql_fetch_assoc ( $result1)) {
        $data_array[$i] = $row1;
	$i++;
     }

    echo "<pre>";
    print_r ($data_array);
    echo "</pre>";
    ?>

The Result is:

    SELECT `IDPENTERED` , `ITEMID` , `QTY` , `VALUE` FROM `tblpieceentered` WHERE `ITEMID`     =307 
    Num rows: 5 

    Array
    (
        [1] => Array
            (
                [IDPENTERED] => 1999
                [ITEMID] => 307
                [QTY] => -1
                [VALUE] => -0.21
            )
     
        [2] => Array
            (
                [IDPENTERED] => 2507
                [ITEMID] => 307
                [QTY] => -10
                [VALUE] => -2.1
            )
    
        [3] => Array
            (
                [IDPENTERED] => 3039
                [ITEMID] => 307
                [QTY] => 1
                [VALUE] => 0.21
            )

    [4] => Array
            (
                [IDPENTERED] => 3040
                [ITEMID] => 307
                [QTY] => -1
                [VALUE] => -0.21
            )

    ) 


Any Ideas?

Thanks
Sean
php_mysql_assoc ignores first record.
===

Hi there I'm trying to query my database to get all the records that share the same "ITEMID" the table is a transaction list of operations done on items in the database.

I've checked the SQL query in phpmyadmin and it works correctly but when I run the php code it ignores the first record every time. Here's my code 
    
    <?php 
     // Get the quantity of each item 
     $sql1 = 'SELECT  `IDPENTERED` ,  `ITEMID` ,  `QTY` ,  `VALUE` FROM  `tblpieceentered` 
      WHERE  `ITEMID` =307 ' ;

     echo $sql1."<br>";

     // Retrieve all the data from the table
     $result1 = mysql_query($sql1)
     or die(mysql_error()); 

     // store the record of the table into $row1
     $row1 = mysql_fetch_array( $result1 ); 
 
     $i = 1; 
     $num = mysql_num_rows ($result1);
 
     echo "Num rows: $num <br>"; 
 
     while ($row1 = mysql_fetch_assoc ( $result1)) {
        $data_array[$i] = $row1;
	$i++;
     }

    echo "<pre>";
    print_r ($data_array);
    echo "</pre>";
    ?>

The Result is:

    SELECT `IDPENTERED` , `ITEMID` , `QTY` , `VALUE` FROM `tblpieceentered` WHERE `ITEMID`     =307 
    Num rows: 5 

    Array
    (
        [1] => Array
            (
                [IDPENTERED] => 1999
                [ITEMID] => 307
                [QTY] => -1
                [VALUE] => -0.21
            )
     
        [2] => Array
            (
                [IDPENTERED] => 2507
                [ITEMID] => 307
                [QTY] => -10
                [VALUE] => -2.1
            )
    
        [3] => Array
            (
                [IDPENTERED] => 3039
                [ITEMID] => 307
                [QTY] => 1
                [VALUE] => 0.21
            )

    [4] => Array
            (
                [IDPENTERED] => 3040
                [ITEMID] => 307
                [QTY] => -1
                [VALUE] => -0.21
            )

    ) 


Any Ideas?

Thanks
Sean