This is a stupid question, but I just can’t find a solution to it, and I feel like there should just be something really obvious that will do it.
Basically, I have a very simple table. What I want to do with this table is return all the rows, and output the data to two different places on my page - one an unordered list, as a menu; the other my main content area, where the same results will appear with a little thumbnail pic, etc.
There’s obviously got to be a better way of doing this than performing the same query twice, but all I can think of is to add the details to a new array inside the first while loop - and that doesn’t seem like a very elegant solution either.
Any help on this would be appreciated. I’ve tried searching but I just can’t even think how to phrase it to get meaningful results!
The way that you suggest seems fine to me - i.e. put them in an array in the first loop.
Possibly more elegant, would be to have one loop at the start, which creates the html required for both, then echo each in the appropriate place in your page.
You would store the results from the first query “somewhere” then just reuse them as and when you want, it really depends on your application structure.