title: Link PHP Image to Specific URL
body: <p>I'm having an issue finding a means to accomplish something. </p>
  
  <p>I have a PHP file that outputs an image by selecting a random one from the database (sort of like a random ad banner).</p>
  
  <p>This allows a user to use the following on their website (separate from mine) to show a random image.</p>
  
  <pre><code>&lt;img src='image.php' /&gt; 
  </code></pre>
  
  <p>However, I also want it to link to a specific URL from the database that matches the image showing. This is where I'm at a road block and can't figure out how to accomplish this. I want it to link to a PHP file on my server (view.php?id=123) and then re-direct to the corresponding URL.</p>
  
  <p>How can I make it redirect to whatever image is currently displayed on the users site. I don't want to use Javascript on the users site. I want the user to be able to use the following:</p>
  
  <pre><code>&lt;a href='view.php?id=123'&gt;&lt;img src='image.php' /&gt;&lt;/a&gt;
  </code></pre>
  
  <p>EDIT: these links would be absolute links to my website and not relative to the users website.</p>
  
  <p>Is there a way of doing this with sessions? </p>
  
  <p>Thanks for any help!</p>