I want to show the same data on the page where the data was extracted from MySQL several times.
First I want to get data from MySQL using mysql_fetch_assoc() in a while loop, and then show it as a menu. The second time I want to show the same data as the site map in the footer.
I am currently mysql_fetch_assoc() twice:
I think the above code can use more resources than required by querying the database twice. Since I have data on the page, to get the same data, memory is again lost, not good.
So my questions are:
mysql_fetch_assoc() it send separate queries and retrieve data from the database every time I use mysql_fetch_assoc() ? Or is it just fetching data from the database once, and then it just goes through the existing array?
What is the best solution in my case?
Simple - Am I doing it in the best way? Is there a better way to do this without wasting memory / resources / time? Since this is the same data that I show twice.
source share