Ya lo solucione, dejo el código por si a alguien le sirve.
   Código PHP:
    $cons4 = "SELECT nombre FROM auxiliar";
    $res = mysql_query($cons4,$c);
    while ($row2=mysql_fetch_array($res)){
        for($i=0; $i<=$row2.length; $i++){
            $nombre = $row2[$i];
            $cons5 = "SELECT cod_art FROM articulos WHERE nombre='$nombre'";
            $res2 = mysql_query($cons5,$c);
            while ($row3=mysql_fetch_array($res2)){
                for($j=0; $j<=$row3.length; $j++){
                    $cod = $row3[$j];
                    $cons6 = "INSERT INTO lineas_fact VALUES ('','$id','$cod','$nombre')";
                    mysql_query($cons6);
                }
            }
        }
    } 
    
  La segunda parte (a partir de cons5) en un ejemplo generico, sobraria, lo unico que hace es recorrer otro campo mas.