I have two tables,
one contains: (category database)
catid (auto increment on insert)
catname (name of category)
subid (if subcategory then is not 0)
the other contains: (items database)
id (auto increment)
name
catid (links category and item database)
I have something that I am having trouble visualizing a solution for. I want to run two queries, saving the data in two seperate arrays. I want to be able to only run two queries to the database, one containing all the info from category database and one containing all the items database information
Currently there is a while loop that renders all the items (unless sorted by another element) on a scrollable, sortable table.
I suppose the question I'm asking is, how do I query the category database once, then run the while loop for items and inside the while loop compare the catid (contained within the items database) to display the appropriate catname (contained with the category database).
The reason I feel I should do this is to avoid unnecessary queries on each loop through the while statement just to find the category name. I also do not want to store the name inside the items database to avoid future appendages to the entire database, in case the end-user decides to alter the name of a category, nothing would be affected except the categories database since the category id will never change but the name the user see is what actually matters.
I have a good background in php and mysql and learned to program when I was 12 but have since been out. Now 10 years later I have hopped back on the scene and my knowledge has increased vastly but I still need help occasionally. If anyone has an answer I'd appreciate it! Or if my question was not specific enough or, perhaps, too verbose please let me know and I'll attempt to restate it.