how to avoid soql in for loop?
To avoid it, best is to execute these SOQL queries, to retrieve the data in bulk, before executing the 'for loop'. Render all the necessary data in a list and iterate over the results.