I'm working on a website, which accesses a database with two tables. One table contains a list of "quests" and the other table contains a list of "items" associated with the quests. The "quests" table has an ID field, which is the primary key, and the "items" table also has an ID field, which is the primary key. The "items" table also has a QID field, which corresponds with the primary ID of the quest it is associated with.
Currently in my code, I have a while loop that gets each quest from the "quests" db table, and puts the information into a html table.. Inside that loop, I have another while loop that goes through the "items" db table and populates the items into the html table. After it's done cycling through all the items, it starts a new row with the next quest.
This works, but it takes up to 15 seconds to populate the table, and it performs 215 queries for the 128 quests and 21 items that I have in the database. Is there a better way to do this?