<style>
div.bookshelf {
	background-image: url(/bookshelf.png);
	background-size: 100% 190px;
	vertical-align: bottom;
	padding-top: 5px;
	border: 10px solid #452211;
	border-bottom: none;
	background-color: #d3e5f4;
}


a.biblio {
	text-decoration: none;
	display: inline-block;
	margin: 0 5px;
	height: 190px;
	vertical-align: bottom;
}

.bookCover {
	box-shadow: 2px 2px 2px 0 rgba(0,0,0,.7);
	max-height: 150px;
}

div.fakeCover {
    background-color: blue;
    background-image: -webkit-linear-gradient(left, transparent, rgba(0, 0, 0, 0.1) 1px, rgba(0, 0, 0, 0.5) 4px, transparent 8px);
    background-image: url(/leather.png), -moz-linear-gradient(left, transparent, rgba(0, 0, 0, 0.1) 1px, rgba(0, 0, 0, 0.5) 4px, transparent 8px);
    background-image:     -ms-linear-gradient(left, transparent, rgba(0, 0, 0, 0.1) 1px, rgba(0, 0, 0, 0.5) 4px, transparent 8px);
    background-image:      -o-linear-gradient(left, transparent, rgba(0, 0, 0, 0.1) 1px, rgba(0, 0, 0, 0.5) 4px, transparent 8px);
    background-image:         linear-gradient(left, transparent, rgba(0, 0, 0, 0.1) 1px, rgba(0, 0, 0, 0.5) 4px, transparent 8px); 
    border: 2px solid rgba(0, 0, 0, 0.5);
    border-radius: 2px 6px 6px 2px;
    width: 110px;
    height: 150px;
    position: relative;
}

div.fakeCover > span.title {
    color: rgba(0,0,0, 0.6);
    background-color: rgba(255,255,255,.2);
    border-radius: 5px;
    border: 1px solid rgba(0,0,0,.05);
    display: block;
    font-family: arial,sans-serif;
    font-size: x-small;
    height: auto;
    margin: 8px;
    margin-left: 15px;
    padding: 2px;
    text-align: center;
    width: 81px;
    max-height: 100px;
    position: absolute;
    top: 0px;
}

div.fakeCover > span.author {
    color: rgba(0,0,0, 0.6);
    background-color: rgba(255,255,255,.2);
    border-radius: 5px;
    border: 1px solid rgba(0,0,0,.05);
    display: block;
    font-family: arial,sans-serif;
    font-size: xx-small;
    height: auto;
    margin: 8px;
    margin-left: 15px;
    padding: 2px;
    text-align: center;
    width: 81px;
    max-height: 100px;
    position: absolute;
    bottom: 0px;
}

</style>
<?php
$dbhost = "127.0.0.1:3306";
$dbuser = "root";
$dbpass = "n03ntry";
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');
$dbname = 'koha';
mysql_select_db($dbname);
$newtitles_sql = "SELECT items.biblionumber AS biblionumber, isbn, title, author, coverlocation FROM ((items JOIN biblio ON items.biblionumber = biblio.biblionumber) JOIN biblioitems on items.biblionumber=biblioitems.biblioitemnumber AND items.biblioitemnumber=biblioitems.biblioitemnumber) LEFT JOIN bibliocovers on items.biblionumber = bibliocovers.biblionumber WHERE dateaccessioned > SUBDATE(SYSDATE(), INTERVAL 31 DAY) AND iType='BOOK'  ORDER BY dateaccessioned DESC";
$newtitles_result = mysql_query($newtitles_sql);
?>
<div class="bookshelf">
<?php
while($row = mysql_fetch_array($newtitles_result)) { 
	$coverlocation = $row['coverlocation'];
	$coverlocationlen = strlen($coverlocation);
print "<div style='display: none;'>$coverlocation</div>";
	echo "<a class='biblio' href='/cgi-bin/koha/opac-detail.pl?biblionumber=".$row['biblionumber']."'>\n";
	if ($coverlocationlen == 4) {
		$color= substr(hash("md5", $row['isbn'].$row['title'].$row['author']), 0, 6);
                echo "<div class='bookCover fakeCover' style='background-color: #".$color.";'><span class='title'>".$row['title']."</span><span class='author'>".$row['author']."</span></div>";
	} else if ($coverlocationlen > 4) {
		echo "<img class='bookCover' src='".$coverlocation."' title='".$row['title']."' author='".$row['author']."' />";	
	} else {
		echo "<img class='bookCover' src='/ltcovers.php?biblio=".urlencode($row['biblionumber'])."&isbn=".urlencode($row['isbn'])."' title='".urlencode($row['title'])."' author='".urlencode($row['author'])."'/>";
	}
	echo "</a>\n";
}
?>
</div>
