YMYL Posted January 7, 2013 Share Posted January 7, 2013 I'm trying to build a page that fetches information from a database: $result2 = $conn->query("select * from votes where pollid='$id'"); for ($count = 0; $row = $result2->fetch_row(); ++$count) { echo $row[2].' Votes:'.$row[3]."<BR>"; } However, the information is needed twice. Once for the CSS portion of the page, and the other for the html page. I can do this with one query but is it possible to do this with one query? I'm thinking this would be best for sever load. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted January 7, 2013 Share Posted January 7, 2013 Why would you need this for the CSS portion of the page? Quote Link to comment Share on other sites More sharing options...
haku Posted January 7, 2013 Share Posted January 7, 2013 Store the result(s) in a variable. Then you can use it as many times as you want without having to re-query each time you want the info. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.