function getattachmentimage($logid){
$db = MySql::getInstance();
$sql = "SELECT * FROM ".DB_PREFIX."attachment WHERE blogid=".$logid." AND (`filepath` LIKE '%jpg' OR `filepath` LIKE '%gif' OR `filepath` LIKE '%png') ORDER BY `aid` ASC LIMIT 0,1";
$imgs = $db->query($sql);
$rowimg = $db->fetch_array($imgs);
if($rowimg['filepath']){
$rand_img = BLOG_URL.substr($rowimg['filepath'],3,strlen($rowimg['filepath']));
}else{
$rand_img = TEMPLATE_URL.'images/postdefimg.png';
}
return $rand_img;
}
?>
网友评论