$result = mysql_query("Select from images where imageID = " . trim(mysql_escape_string($_GET['imageID'])));
$row = mysql_fetch_assoc($result);
switch ($row['imageType']){
case 'jpeg': header('Content-Type: image/jpeg');
//etc
} //end switch
//get the image size
$length = filesize('/path/to/image/'. $row['imageFileName']);
header('Content-Length: ' . $length);
//now send the image
readfile('/path/to/image/'.$row['imageFileName']);
exit(); //kill the script