title: mysql with many tables
body: <p>I have a major problem getting this to work properly. Here is the deal. </p>
  
  <p>I have 4 tables - <code>timeline</code>, <code>connections</code>, <code>images</code>, <code>votes</code></p>
  
  <p><strong>Timeline table:</strong></p>
  
  <pre><code>time_id
  time_title
  </code></pre>
  
  <p>etc.</p>
  
  <p>The timeline table connects with the images table via the connections table</p>
  
  <p><strong>Connections table:</strong></p>
  
  <pre><code>time_id
  image_id
  </code></pre>
  
  <p>So the connections hold information about the id of the "post" the timeline and about image id</p>
  
  <p><strong>Images table:</strong></p>
  
  <pre><code>image_id
  image_url
  image_type
  </code></pre>
  
  <p>Images table contains images that could be used in the same timeline(post), so by this i can see the connection by looking at the connection table.</p>
  
  <p>I also have a votes table that holds information about votes for the specific timeline post</p>
  
  <p><strong>Votes table:</strong></p>
  
  <pre><code>vote_id
  time_id
  </code></pre>
  
  <p>the votes table contains many rows of each time_id and the idea is to count the number of times to se wich is the most popular</p>
  
  <p>So heres the question:
  I need to get the 5 most voted time_titles and show them with the first image for each time_title(post) so that it look like this for example</p>
  
  <ul>
  <li>Image 1 that corresponds to Title 1 - that is the highest voted  </li>
  <li>Image 2 that corresponds to Title 2 - that is the second highest voted   </li>
  </ul>
  
  <p>etc.</p>
  
  <p>Each timeline row (post) can hold many images and i only want to show the first of each post.</p>
  
  <p>Hope you understand my problem! </p>
  
  <p>Thanks a lot! </p>