title: MySQL SELECT from two tables based on ID from URL
body: <p>I have a problem. I'm new in MySQL. So far, I've needed only simple queries, and everything worked fine. But, now I have a problem. I have two tables:</p>
  
  <ol>
  <li><p>table <code>tarife</code></p>
  
  <pre><code>+----+---------------+
  | id |  ime_tarife   |
  +----+---------------+
  |  1 | Neka tarifa 1 |
  |  2 | Neka tarifa 2 |
  +----+---------------+
  </code></pre></li>
  <li><p>table <code>telefoni_dodatak</code></p>
  
  <pre><code>+----+--------------+-----------+-------+
  | id | telefoni_id  | tarifa_id | price |
  +----+--------------+-----------+-------+
  |  1 |           35 |         1 |   650 |
  |  2 |           35 |         2 |   700 |
  +----+--------------+-----------+-------+
  </code></pre></li>
  </ol>
  
  <p>All values in this table are integers.</p>
  
  <p>I have URL like this <code>www.example.com/phones/35/</code> where number 35 represents id of the page (used in some third table), and it's also writen as <code>telefoni_id</code> in table <code>telefoni_dodatak</code>.</p>
  
  <p>Column <code>tarifa_id</code> have id numbers from table <code>tarife</code>.</p>
  
  <p>I have to get output like this in HTML, based on id from url <code>www.example.com/phones/35/</code>:</p>
  
  <pre><code>Neka tarifa 1 | 650
  -------------------
  Neka tarifa 2 | 700
  </code></pre>
  
  <p>I've tried with this query:</p>
  
  <pre><code>SELECT *, (SELECT ime_tarife FROM tarife WHERE id = (SELECT tarifa_id FROM telefoni_dodatak WHERE telefoni_id = :id)) AS nazivTarife FROM telefoni_dodatak WHERE telefoni_id = :id
  </code></pre>
  
  <p>but that don't work. (<code>nazivTarife</code> is not defined. Should be?)</p>
  
  <p>I'm using PDO, and <code>:id</code> is that number 35 from url.</p>
  
  <p>P.S. This query <code>SELECT * FROM telefoni_dodatak WHERE telefoni_id = :id</code>works fine, I'm getting both prices 650 and 700.</p>
  
  <p>Thanks in advance for any help!</p>