Código PHP:
<?php
$consulta1="SELECT * FROM detallepedido WHERE Id_Pedido='".$idPedido."'";
$result1=mysql_query($consulta1) or die( mysql_error());
?>
<table style="height:100%;width:100%;" border="0" align="center">
<table style="border:1px solid #FF0000; color:#000099;width:100%;">
<tr style="background:#99CCCC;">
<td>Referencia</td>
<td>Artista</td>
<td>Disco</td>
<td>Precio</td>
<td>Cantidad</td>
<td>Total</td>
</tr>
<?php
$total=0;
while($row = mysql_fetch_array($result1))
{
$idarticulo=$row['Id_Articulo'];
$cantidad=$row['Cantidad'];
$consulta2="SELECT RefNom, RefNum, Artista, Disco, PVPMenor FROM articulos WHERE Id_Articulo='".$idarticulo."'";
$result2=mysql_query($consulta2) or die( mysql_error());
$row1 = mysql_fetch_array($result2);
$precio=$row1['PvPVenta'];
$tot=$cantidad*$precio;
$total=$total+$tot;
$referencia=$row1['RefNom'].$row1['RefNum'];
echo "<tr>";
echo "<td>".$referencia."</td>";
echo "<td>".$row1['Artista']."</td>";
echo "<td>".$row1['Disco']."</td>";
echo "<td>".$row1['PVPMenor']."</td>";
echo "<td>".$row['Cantidad']."</td>";
echo "<td>".$tot."</td>";
echo "</tr>";
}
echo"<tr><td colspan='6' align='right'><b>Total:</b> <input align='right' size='14' readonly style='text-align:right' type='text' readonly value=".$total."€"."></td></tr>";
?>
</table>