So I search for this title hoping someone would have already answered it however, I came across similar topics on other languages but not PHP so maybe this will help others. 

I am constantly using this following script to call on the database but how can I create it so that I can make it just once at the top of the class for example and use it in every method on the class page that needs it. Example: An single page may not have all of the data it needs from the same table but if the table contains 50% of the data or more for that page, how can I modify this so that I can just say it once and let the rest of the following scripts display the data it extracted in the first place by calling it all just once?

Here's what I have now.

```
<?php
    if($res = $dbConn->query("SELECT Column FROM Table")){
        while($d = $res->fetch_assoc()){
            printf("Enter HTML here with proper %s", $d['Column']);
        }
    }
?>

```

I want to call on this without the `printf(" ");` collect and store the data so that I can then call the results while printing or echoing the results with the HTML in other methods. What os the most efficient way? I don't want to make the same call over and over and over... well, you get the point.

Should I use fetch\_array or can I still do it with fetch\_assoc?