Seems to be some issues around your while, (missing <?php tag).
The name of the field index keys should really be the index e.g.
<input type="hidden" name="BarCode[<?php echo $r["Id"] ?>]" />
This way you do not need the Id field.
You should receive an array of with the indexes the Ids of each BarCode.
foreach ( $_POST["BarCode"] as $id => $value )
mysql_query( sprintf( "UPDATE product SET Serial = %s WHERE Id = %d", mysql_real_escape_string( $value ), mysql_real_escape_string( $id ) ) );
Ideally of course you should use a prepared statement for this which would make the update much easier, look into [man]PDO[/man]
Hope this helps a bit.