1

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);
}
ultranaut
  • 2,132
  • 1
  • 17
  • 22
anastasia
  • 31
  • 1
  • 3
  • In sql libraries there'll be a function on the return value that'll return the next row while there are rows left. Call that in the loop while it still has rows remaining (will be another function) – Patashu Mar 13 '13 at 01:05

2 Answers2

1

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

Community
  • 1
  • 1
Jeffrey Nicholson Carré
  • 2,950
  • 1
  • 26
  • 44
0

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);
}
}
Wesley Brian Lachenal
  • 4,381
  • 9
  • 48
  • 81
  • i still get the same output considering that i replaced $value in the $value->FILEDATA line with $data because it does not work. :( – anastasia Mar 13 '13 at 01:52