|
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]
|