Prueba:
Código PHP:
$suma = mysql_query("SELECT SUM(cantp) as total, SUM(cant_ent) as ent, SUM(cant_rest) as rest FROM sub_pedidos where cod_pedido=$ped[codigo]" ,$conexion);
$datos = mysql_fetch_array($suma);
$total = $datos["total"];
$ent = $datos["ent"];
$rest = $datos["rest"];