I have a problem getting images from a database to display on a webpage. I can call the image by its id # with no problem, but the image is shown as ascii if I call it via an array. How can I make it work with the array? I don't want to have to code in the id #s for each image.
Here is the code to show the images, you can see it in action on this page: http://thor.osd.wednet.edu/~conorjr/news/nnews/test.php
<HEAD><TITLE>Test</TITLE></HEAD><BODY>
<P><IMG SRC=news2.php?id=10>
<?
mysql_connect("localhost","*********","***");
mysql_select_db("*******");
$show = mysql_query("select * from news ORDER BY id desc");
WHILE($news = mysql_fetch_array($show)) {
echo "<P>Image: <IMG SRC='$news[image]'>";
echo "<P>Description: $news[description]";
}
?>
</BODY>
Here is news2.php:
<?
if ($id) {
mysql_connect("localhost","*****","******");
mysql_select_db("********");
$query = "select image,filetype from news where id=$id";
$result = @($query);
$data = @MYSQL_RESULT($result,0,"image");
$type = @MYSQL_RESULT($result,0,"filetype");
Header( "Content-type: $type");
echo "$data";
};
?>