images php coding issues or problems here.
Moderators: macek, egami, gesf
by 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.
-
aceminer
- New php-forum User

-
- Posts: 8
- Joined: Fri Sep 23, 2011 7:00 am
by 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 ).
-
NigelRen
- php-forum Active User

-
- Posts: 450
- Joined: Fri Aug 05, 2011 9:53 am
by 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
-
aceminer
- New php-forum User

-
- Posts: 8
- Joined: Fri Sep 23, 2011 7:00 am
by 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.
-
PlaviZG
- New php-forum User

-
- Posts: 7
- Joined: Fri Sep 23, 2011 12:47 pm
by 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.
-
NigelRen
- php-forum Active User

-
- Posts: 450
- Joined: Fri Aug 05, 2011 9:53 am
Return to PHP coding => Images
Who is online
Users browsing this forum: No registered users and 1 guest