anastasia
anastasia

Reputation: 31

How to display/ retrieve all images from the database

I want to display all Images 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

Answers (2)

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

Brian Coolidge
Brian Coolidge

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

Related Questions