Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => Images

Display php generated images from database

images php coding issues or problems here.

Moderators: macek, egami, gesf

Display php generated images from database

Postby Xdes » Mon Jul 04, 2005 4:30 am

Hello ,

I would like to display pictures with displaying the actual picture with php.
I found out that it is pretty easy to do this with 1 picture and a copyright watermark, also thumbnails are easily created from a large image.

My question:
Now I have a database(mysql) that contains filenames+paths of all images, now I would like to display 10 thumbnails at a time on each page with using a pagination system.
I'm thinking about displaying the (PHPimages within IFRAMEs, that is not a problem, the problem is:
How do I get an image path+filename (from the database) on my "image.php" file?
Or it maybe impossible..?

---------------------------------------------------------------------
Ofcourse I could just show the images the easy way without php generated images, but the reason that I want to use php generated images is because:

- Make the loading time much faster (smaller file size)
- I can easily use a copyright image without modifying the original images.

Thats why I want to use PHP generated images.

Another question, does this code work for both PHP 4 and 5?

Can anyone help me out?

See the code I use:

This code is to get the image file name + the path from the database:
Code: Select all
<? echo $row_phqs['location'] ?><? echo $row_phqs['file']; ?>


How do i put that code into this :
Code: Select all
<?php
$img = imagecreatefromjpeg('How do i get the path of my image source here');
.......................................
?>


Who can :help: me out?

Or is it impossible the way i want to do this? :?
Last edited by Xdes on Wed Jul 06, 2005 6:27 pm, edited 1 time in total.
User avatar
Xdes
New php-forum User
New php-forum User
 
Posts: 2
Joined: Mon Jul 04, 2005 4:06 am

Postby gesf » Tue Jul 05, 2005 5:53 am

Code: Select all
<?php

$img_path = $row_phqs['location'] . $row_phqs['file'];
$img = imagecreatefromjpeg($img_path);

?>
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby Xdes » Tue Jul 05, 2005 6:40 pm

gesf wrote:
Code: Select all
<?php

$img_path = $row_phqs['location'] . $row_phqs['file'];
$img = imagecreatefromjpeg($img_path);

?>



Thanks for your solution, but it did not work..

With using this code I get an "headers already sent" error.

It works for 50%, I see the images in the iframes, only they are in TEXT format, i should be in IMAGE/JPEG, the problem has to do with "headers already sent".

Any other solution?
Last edited by Xdes on Wed Jul 06, 2005 6:25 pm, edited 1 time in total.
User avatar
Xdes
New php-forum User
New php-forum User
 
Posts: 2
Joined: Mon Jul 04, 2005 4:06 am

Postby Alexej Kubarev » Wed Jul 06, 2005 12:42 am

the problem is that you have to send those headers before anything else.

There are several ways, one of them would be setting output_buffering to on in php.ini
You may also want to use php internal buffering: ob_start(), ob_end(), ob_get_content(), ob_clean() and so on are prety usefull
User avatar
Alexej Kubarev
Site Admin
Site Admin
 
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län

Postby gesf » Wed Jul 06, 2005 4:20 am

Oh! Ok... do what Alexei said :)
User avatar
gesf
Moderator
Moderator
 
Posts: 1718
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Postby Alexej Kubarev » Wed Jul 06, 2005 4:31 am

hehe gesf ;)
User avatar
Alexej Kubarev
Site Admin
Site Admin
 
Posts: 2223
Joined: Fri Mar 05, 2004 7:15 am
Location: Täby, Stockholms län


Return to PHP coding => Images

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.