Funktionen ser sådanne ud:
<?
function showImage($idartikel){
include("includes/config.inc.php");
$idartikel = $_REQUEST['pageid'];
$sql = "SELECT * FROM artikel_images WHERE idartikel = '$idartikel'";
#echo $sql;
$result = mysql_query ($sql);
if (mysql_num_rows ($result)>0) {
$row = @mysql_fetch_array ($result);
$image_type = $row["image_type"];
$image = $row["image"];
Header ("Content-type: $image_type");
return $image;
}
}
?>
----------------
Der hvor jeg henter funktionen ud ser sådanne ud:
<?
#header("Content-type: image/jpeg");
include("includes/config.inc.php");
include_once("includes/meta.php");
include_once("includes/functions.php");
include("admin/lib/vis_artikel.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="
http://www.w3.org/1999/xhtml"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><? echo $metatitle; ?></title>
<meta name="Keywords" content="<? echo $metakeywords; ?>" />
<meta name="Description" content="<? echo $metadescription; ?>" />
<link href="css/andigena.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" type="text/javascript">
var bookmarkurl="
http://www.andigena.dk"var bookmarktitle="Andigena Rejser"
function addbookmark(){
if(document.all)window.external.AddFavorite(bookmarkurl,bookmarktitle)
}
var theImages = new Array() // do not change this
theImages[0] = 'images/top-images/front.jpg'
theImages[1] = 'images/top-images/pool.jpg'
// do not edit anything below this line
var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
preBuffer[i] = new Image()
preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'" alt="" title="" width="762" height="160" border="0">');
}
</script>
</head>
<body>
<table width="762" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td id="header">
<? $idartikel = $_REQUEST['pageid'];?>
<? $image = showImage($idartikel);?>
</td></tr></table>
</body>
</html>