title: How do I keep a SQL connection throughout a webpage?
body: <p>Let's say I'm creating a basic page, said page's text varies depending on what's passed into it through a GET variable.</p>
  
  <p>There's a header at the top of the page like so:</p>
  
  <pre><code>&lt;?php 
  mysql_connect("stuff", "stuff", "stuff");
  mysql_select_db("dbname");
  mysql_query("SELECT * FROM table WHERE ID = '{$_GET['url']}'");
  
  //Now we have connected to the SQL database.
  ?&gt;
  </code></pre>
  
  <p>Assuming I continued coding there, so that the header text varied depending on what was passed into the URL (however, this is irrelevant, it's the next part in which I want to question).</p>
  
  <p>Now let's say that, further down the page, there is some more PHP code, but there is also more HTML code in between. If I wanted to access the database again in this second PHP snippet, do I have to reconnect to the database? Or is there a way I can make sure that the connection session stays open, even when it's a completely different <code>&lt;?php ?&gt;</code> area? How do i make it so that my SQL connection isn't dropped when I end the <code>&lt;?php</code> tag?</p>