My website take too much to load.I want to show a table on top of page and on bottom of page.
To get the same result twice,I am using same query two times.What is the best way to fetch data only once so that we improve speed?
Here is my code AT TOP
$q_s ="SELECT id,ref,name,description FROM TABLE WHERE status=2 AND is_archive=0
ORDER BY id DESC limit 5";
$res = $objApp->query($q_s);
while($rw = $objApp->row($res)){
//display my data here in div1
}
AT BOTTOM
$q_s2 ="SELECT id,ref,name,description FROM TABLE WHERE status=2 AND is_archive=0
ORDER BY id DESC limit 5";
$res2 = $objApp->query($q_s2);
while($rw = $objApp->row($res2)){
//display my data here in div2
}
NOTE:DIV1 and DIV2 are two different html.Also i showed only simplest query,its too complecated in my case.
How can i improve it?Sorry i am new to PHP