Try joining the tables instead of running queries within a loop (which is typically a bad idea. The following is untested and hastily put together, but it looks like it could work for your purposes:
SELECT a.id_art
,a.denom2
,a.exist
,a.marca AS articulosMarca
,m.id_marca
,m.marca AS marcasMarca
FROM equiva e
LEFT JOIN articulous a
ON (a.id_art = e.codigo1 OR a.id_art = e.codigo2)
LEFT JOIN marcas m
ON m.id_marca = a.marca
WHERE ((e.codigo1 LIKE %$artic%) OR (e.codigo2 LIKE %$artic%))
Again, it's untested, but I think I covered your criteria.