You are here: Image displaying « All PHP « IT news, forums, messages
Image displaying

Posted by ljuljacka on 10/08/06 12:46

I'm trying to display resized images. Locations of images are fetched from
database. The problem is that with the following code, I get only the first
image displayed:

[PHP]
<?php
header('Content-type: image/jpeg');

$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}

mysql_select_db("proba1");
$query='select lokacija from galerija';
$result=mysql_query($query);
$new_width = 200;
$new_height = 150;


while($filename=mysql_fetch_array($result)){

for($i=0;$i<=count($filename);$i++){

list($width, $height) = getimagesize($filename[$i]);
$image_p = imagecreatetruecolor($new_width, $new_height);
$image = imagecreatefromjpeg($filename[$i]);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width,
$new_height, $width, $height);
imagejpeg($image_p, null, 100)."\n";
imagedestroy($image);
imagedestroy($image_p);
}
}
[/PHP]

With the next code in the same for loop I get all of the images, but
ofcourse not resized:

[PHP]
....
echo "<table>";
echo"<tr><td><img src=$filename[$i]></td></tr>";
echo "</table>";
....
[/PHP]

So I guess the problem is in image functions, but I don't know how to solve
it. Any suggestion is welcome :)

Tnx,
Dejan

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация