|  | Posted by gooze on 01/15/06 01:05 
Hello
 I am working on an applicaion that shows several pictures on a webpage.
 These pictures are saved in a MySQL DB as BLOB. I noticed, that the web
 server suffers in its performance by printing the pictures. Let's say
 there are 20 pictures to show, there also are 20 queries to do. This is
 the way I am doing it up to now:
 
 index.php
 <?php
 foreach ($icons as $value) {
 echo '<img src="./show_icon.php?icon_id=' . $value . '">';
 }
 ?>
 
 show_icon.php
 <?php
 $query = "SELECT icon FROM pictures WHERE id='$_GET['icon_id'] ";
 $result = @mysql_query ($query) or die (mysql_error());
 $icon = @mysql_result ($result, 0, "icon");
 
 header("Content-type: image/png");
 echo $icon;
 ?>
 
 Actually this works quite well, but the performance is an issue. Is
 there a more simple or more elegant way than the code above? Is there
 actually a solution to do it with one query instead of 20 queries?
 
 Thanks for your help
 Stefan
  Navigation: [Reply to this message] |