<?php header('Content-type:text/xml'); 
print '<?xml version="1.0" encoding="utf-8"?>';
?>

<rss version="2.0">

<channel>
<title>Brown University Digital Bookplates</title>
<description>Brown University Library digital bookplates recognize the support of endowments and gifts in building
collections and supporting all aspects of  Library work.</description>
<link>http://worf.services.brown.edu/bookplates</link>
<copyright>2005 Brown University Library. All rights reserved.</copyright>

<?php

require ('/var/www/common/guest_connect.php');

 	$range_result = mysql_query( " SELECT MAX(`item_id`) AS max_id , MIN(`item_id`) AS min_id FROM bookplates.items ");
	$range_row = mysql_fetch_object( $range_result );
	$random = mt_rand( $range_row->min_id , $range_row->max_id );
	$result = mysql_query( "


	SELECT name, title, bibno, item_id FROM bookplates.endowments
	LEFT JOIN bookplates.items USING (account)
	WHERE title != \"\" AND name != \"\" AND item_id >= $random
	GROUP BY name
	ORDER BY bibno
	LIMIT 0,100 ")
	;

#	$result = mysql_query($query);

	while($row = mysql_fetch_array($result)){

	$title= $row['title'];
	$title = htmlentities(strip_tags($title));
	$title = substr($title,0,125);
	$name = $row['name'];
	$name = htmlentities(strip_tags($name,'ENT_QUOTES'));
	$bibno = $row['bibno'];

	echo "
     <item>
        <title>$title</title>
        <description>Purchased with the $name</description>
        <link>http://josiah.brown.edu/record=$bibno</link>
     </item> 
	";

	} 
?>
</channel>
</rss>

