<?php echo '<?xml version="1.0"?>', "\n"; ?>
<recommendation>
<songs>
<?php

$search_db = pg_pconnect('localhost', '', '', '', 'gnomoradio-search');

$result = pg_exec($search_db, 'select songs.name, songs.url, artists.name, random() as randomorder from songs, artists where artists.id = songs.artist order by randomorder limit 10');
if ($result) {
	for ($i = 0; $i < pg_numrows($result); $i++) {
?>
<song url="<?php echo pg_result($result, $i, 1); ?>">
<title><?php echo pg_result($result, $i, 0); ?></title>
<artist><?php echo pg_result($result, $i, 2); ?></artist>
</song>
<?php
	}
	pg_freeresult($result);

	// counter
	pg_freeresult(pg_exec($search_db, 'update recommend_counter set count = count + 10'));
}

?>
</songs>
</recommendation>
