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. Link to comment https://forums.phpfreaks.com/topic/272800-possible-to-do-in-one-query/ 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? Link to comment https://forums.phpfreaks.com/topic/272800-possible-to-do-in-one-query/#findComment-1403920 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. Link to comment https://forums.phpfreaks.com/topic/272800-possible-to-do-in-one-query/#findComment-1403924 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.