title: PHP: SQL from two queries - ignore duplicates
body: <p>So I have this piece of code. It retreives a list of rooms from the table "rom" and is then supposed to check this against the same rooms in "booket". How can I just print out the rooms that are NOT in booket in the set time.</p>
  
  <p>"Rom"-database looks like this:</p>
  
  <pre><code>romnavn   | romtype (not relevant here)
  
  ex: 81-77 | 2
  </code></pre>
  
  <p>"Booket" looks like:</p>
  
  <pre><code>romnavn   | bruker      | dato       | fra | til
  
  ex: 81-77 | foo@bar.net | 03.04.2013 | 16  | 18
  </code></pre>
  
  <p>(this means that the room will be booked from 16:00:00 to 18:00:00)</p>
  
  <p>If the room shows up in both queries it should be ignored.</p>
  
  <p>My guess was two while-loops, "<code>$notFreeA</code>" inside the first one, but I'm not getting the result I want.</p>
  
  <p>I'm fairly sure that both the DB and queries are, well..,bad, but any help would be very much appreciated :)</p>
  
  <pre><code>require "sql/sqlConnect.php";
  require "functions/functions.php";
  date_default_timezone_set('Europe/Oslo');
  $time = date('H:i:s');
  $date = date('d.m.Y');
  $nearestHour = roundToNearestHour($time);
  
  $allRooms = "SELECT * FROM rom";
  $notFree = "SELECT * FROM booket WHERE dato='$date' AND fra&lt;='$nearestHour';";
  
  $allRoomA = mysql_query($allRooms);
  $notFreeA = mysql_query($notFree);
  </code></pre>
  
  <p>The function to round up/down to nearest room looks like this:</p>
  
  <pre><code>function roundToNearestHour($time) {
  $part = explode(":", $time);
  
  if(count($part) != 3)
    return 0;
  
  if($part[2] &gt; 30)
    $parts[1]++;
  
  if($part[1] &gt; 30)
    $part[0]++;
  
  return $part[0];
  }
  </code></pre>