<?php

require 'header.php';

if ( isset($_REQUEST['queueid']) ) {
   $queueid = intval($_REQUEST['queueid']);
} else {
   exit();
}

$fields = array();
if ( $queueid == 0 ) {
   $query = "INSERT INTO " . INSTANTQTABLE . " (songid) SELECT id FROM " . SONGSTABLE . " WHERE id NOT IN (SELECT songid FROM " . INSTANTQTABLE . ") AND genre <> 'Christmas' ORDER BY RAND() LIMIT " . SONGSPERSURPRISE;
} else {
   $query = "INSERT INTO " . INSTANTQTABLE . " (songid) SELECT songid FROM " . QUEUECONTENTSTABLE . " WHERE songid NOT IN (SELECT songid FROM " . INSTANTQTABLE . ") AND qid=:qid ORDER BY RAND() LIMIT " . SONGSPERSURPRISE;
   $fields[':qid'] = $queueid;
}
$sth = $globaldbh->prepare($query);
$sth->execute($fields);
//echo "<pre>"; print_r($songs); echo "</pre>"; exit();

?>
