Displaying images

images php coding issues or problems here.

Moderators: macek, egami, gesf

aceminer
New php-forum User
New php-forum User
Posts: 8
Joined: Fri Sep 23, 2011 7:00 am

Displaying images

Postby aceminer » Fri Sep 23, 2011 7:36 am

Hi guys, just to check. What would be the best way to display a picture on a web site? Would it be better to store it in a database or is there any way we can load pictures on a php webpage? Assuming the number of pictures i would have to store would be about 100.

NigelRen
php-forum Active User
php-forum Active User
Posts: 450
Joined: Fri Aug 05, 2011 9:53 am

Re: Displaying images

Postby NigelRen » Fri Sep 23, 2011 10:16 am

IMHO - I would store the images just in a directory on the server. You can have a record in a database which has some form of identifier, as well as the name of the file.
Storing the image itself in the database is only useful if you were doing things like replication or clustering. This is just so that all the information is in the same system ( the database ).

aceminer
New php-forum User
New php-forum User
Posts: 8
Joined: Fri Sep 23, 2011 7:00 am

Re: Displaying images

Postby aceminer » Fri Sep 23, 2011 10:18 pm

Hmm... Well but if there is a lot of images? Could you give me any ideas if I want to display a picture per web page is there any ways I can do it with minimal developer effort? Such as refreshing the page but just changing the picture once a button is clicked? Such as if I click a button next an image comes out. And if I press it again a different image comes out but the page contents remain the same

PlaviZG
New php-forum User
New php-forum User
Posts: 7
Joined: Fri Sep 23, 2011 12:47 pm

Re: Displaying images

Postby PlaviZG » Sat Sep 24, 2011 5:57 am

The practice is to store image path in the database and store images to server. after that u can use any kind of display like lightboxes ect.

NigelRen
php-forum Active User
php-forum Active User
Posts: 450
Joined: Fri Aug 05, 2011 9:53 am

Re: Displaying images

Postby NigelRen » Sat Sep 24, 2011 8:35 am

aceminer wrote:Hmm... Well but if there is a lot of images? Could you give me any ideas if I want to display a picture per web page is there any ways I can do it with minimal developer effort? Such as refreshing the page but just changing the picture once a button is clicked? Such as if I click a button next an image comes out. And if I press it again a different image comes out but the page contents remain the same


This is more about HTML/Javascript, you can just use Javascript to change the HTML to have a different image name. You could use AJAX to call a PHP script to give you which image to display and again then update the HTML.
Have a look at http://www.w3schools.com/php/php_ajax_php.asp for AJAX code.


Return to “PHP coding => Images”

Who is online

Users browsing this forum: Google [Bot] and 1 guest