Latest images function

hello!
i just wrote a simple function for showing latest images. if someone is interested here it is:

put it at the end of zen/functions.php

function show_latest_images($number) {
$sql = "SELECT * FROM ". prefix("images") ." ORDER BY id DESC LIMIT $number";
$result = mysql_query($sql);

echo '<div id="latest_images">';

while($r = mysql_fetch_array($result)) {
echo '<div class="imagethumb">';
if ($conf['mod_rewrite'] == false) {
echo '';
} else {
echo '
';
}
echo '<img src="'.WEBPATH.'/cache/'.get_album_name($r['albumid']).'_'.$r['filename'].'_100_cw85_ch85.jpg" border="0">
';
echo '</div>';
}
echo '</div>';

}

function get_album_name($id) {
$sql = "SELECT * FROM ". prefix("albums") ." WHERE id = $id";
$result = mysql_query($sql);

while($r = mysql_fetch_array($result)) {
return $r['folder'];
}
}

when edit your theme and put <?php show_latest_images(5) ?> where you want your images to be
working demo can be found here http://lovart.gektoras.lt/

Comments

Sign In or Register to comment.