title: how do i write certain commands and call them into a page in php
body: <p>I have a page that is using alot of mysql queries.
  Is there a way i can write one php file and call these queries into any page ?</p>
  
  <p>Example :
  Lets say i have 50 of the below queries in a php file (there are 50 different queries)</p>
  
  <hr>
  
  <pre><code>&lt;?php
       include_once("db.php");
  
        session_start();
  if(isset($_SESSION['affID'])) {
  
  }
  
  $sql = "SELECT SUM(AffPaid) as c FROM toutcome WHERE affID = '" . $_SESSION['affID'] . "'";
  $result = mysql_query($sql);
  $row = mysql_fetch_array($result);
  echo "£" . $row['c'] ; 
  
  ?&gt;
  </code></pre>
  
  <hr>
  
  <p>Can i not do the following ?</p>
  
  <pre><code>**$query1 =**
  
  &lt;?php
       include_once("db.php");
  
        session_start();
  if(isset($_SESSION['affID'])) {
  
  }
  
  $sql = "SELECT SUM(AffPaid) as c FROM toutcome WHERE affID = '" . $_SESSION['affID'] . "'";
  $result = mysql_query($sql);
  $row = mysql_fetch_array($result);
  echo "£" . $row['c'] ; 
  </code></pre>
  
  <p>then in any page say echo $query1 ?</p>