Reputation: 31
I want to display all Image
s from the database but my code here displays only one. How can I get them all and display in my webpage. I know I need to put a loop but I wonder where it should be.
Here's my php code so far (without loop)
include('../include/connect.php');
$query=ibase_query("SELECT FILEDATA FROM ARCHIVE WHERE FILE_TYPE='Image'");
$data=ibase_fetch_object($query);
if($data){
header("Content-type:image/jpeg || image/gif || image/png || image/pjpeg");
ibase_blob_echo($data->FILEDATA);
}
Upvotes: 1
Views: 838
Reputation: 3040
Each time you use ibase_fetch_object
it gets the next object
so you could uset it in a while loop (php example) :
header("Content-type:image/jpeg || image/gif || image/png || image/pjpeg");
while ($data=ibase_fetch_object($query){
ibase_blob_echo($data->FILEDATA);
}
EDIT : following this answer you should have 2 separate files
Upvotes: 1
Reputation: 4649
Well, dunno if this works but, you might as well consider use foreach loop.
foreach ($data as $value) {
if ($value) {
ibase_blob_echo($value->FILEDATA);
}
}
Upvotes: 0