hi,
are you storing the images in the database or just the path to the images?
Also I always set the query to die if it fails and output the mysql error when it does IE
$result = mysql_query("SELECT * FROM files ORDER BY fid") or die(mysql_error());
Richard
rickya100
Junior Poster in Training
78 posts since Mar 2008
Reputation Points: 13
Solved Threads: 1
I'm trying to display in a web page all the images stored in a database. THis is my code, but it only displays the first picture:
<?php
include "cysylltiad.php";
$result = mysql_query("SELECT * FROM files ORDER BY fid");
while($row = mysql_fetch_array($result)){
header("Content-Type: {$row['type']}");
echo $row["content"];
}
?>
where content is the name of the picture field.
Any help would be appreciated.
in my mind, this should produce a row of images
the content-length header should tell the browser where to break the image,
untested, I do not use blobs
blobs in databases are slow, processor intensive and unneccesarily large, my databases just store the file system pointer to the image
while($row = mysql_fetch_array($result)){
header("Content-Type: {$row['type']}");
header("Content-Length: strlen($row['content'])");
echo $row['content'];
}
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
almostbob
Posting Sensei
3,149 posts since Jan 2009
Reputation Points: 571
Solved Threads: 376
I've never stored images as BLOB in a DB as every article I've ever read says to not do. I find it much easier (once you learn it) just storing the path in the database and storing the actual files in a folder.
I know that doesn't help. If it's possible I would change to just storing the path, if not I hope someone with experience of BLOBs can help.
Good luck
rickya100
Junior Poster in Training
78 posts since Mar 2008
Reputation Points: 13
Solved Threads: 1