Disculpa mi ignorancia. Espero ahora no poner datos de mas ni de menos. Te refieres a lo siguiente?:
Código HTML:
1 - $datosempresaaa = @mysql_fetch_array(mysql_query("SELECT * FROM peru NATURAL LEFT JOIN peru_import_partida LEFT OUTER JOIN peru_empresas ON peru.ruc = peru_empresas.ruc_nvo WHERE id='".$ttempresaid."' limit 1"));
2 - $_pagi_sql = "SELECT * FROM peru";
3-$result = mysql_query("SELECT * FROM peru_export WHERE empresa='$empresa_operativa' ORDER BY id ASC LIMIT 1", $con);
if ($row = mysql_fetch_array($result)){
while ($field = mysql_fetch_field($result)){
}
4 - $tabla = mysql_query("SELECT DISTINCT * FROM peru_import_partida LEFT OUTER JOIN ncm_4_dig ON peru_import_partida.partida = ncm_4_dig.ncm WHERE ruc='$ruc' LIMIT 3");
while ($registro = mysql_fetch_array($tabla)) {