Can I sync music from iphone into itunes library? (music lost)?

I recently lost everything on my computer due to a virus so i had to reinstall itunes.

When i logged into my itunes account my purchased music was there, but i was wondering if there was any way i could get my downloaded music back into my library without locating the folder on my computer bc that got erased too.

The online music is still on my phone & ipod but i would like it in the library too.

I would appreciate any help or advice, thanks.

"can I sync music from iphone into itunes library?"

No. You can only sync to a device; you can use the "transfer purchase" option but only stuff purchased on iTunes. There are ways to get them back but that will require 3rd party software which you can read about by checking the answers given to the last 500 people to have already asked this question.

"The online music is still on my phone & ipod but i would like it in the library too."

Then you should have copied to a flash drive. Routine back ups would likely miss some files but if you did it regularly enough it would mean the difference between a few lost songs and everything.