Displaying images retrieved from database using PHP -
i know how display image stored in database inside of particular div
using php code?
the code used looks that:
<form method="post"> <input type="button" name="show" value="show"/><br/> <input type="image" id="image_show" name="img" value="img"/> </post> if(@$_post['show']) { $sql="select imagedata form images order desc"; $result=mysql_query($sql) or die('invalid query'.mysql_error()); //set header header("content-type:image/png"); echo mysql_result($result,0); while( $row = mysql_fetch_row( $result ) ) { echo "<img src='".$row[0]."'/>"; } }
but not work. how can solve task?
you need specify name of column want retrieve returned array (imagedata
in case)
echo '<img src="'.$row['imagedata'].'"/>";
also, if dont need line if want show image , force download:
//set header header("content-type:image/png");
it throw error anyway printing information before form.
Comments
Post a Comment