batstanggt Posted August 6, 2011 Share Posted August 6, 2011 Is it possible to use php to get images from a database and display them in a slideshow format? Or is that only possible through the cursed javascript? -SB Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/ Share on other sites More sharing options...
trq Posted August 6, 2011 Share Posted August 6, 2011 Of course it's possible. PHP generates whatever markup you tell it to. Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1252945 Share on other sites More sharing options...
batstanggt Posted August 6, 2011 Author Share Posted August 6, 2011 So then how does one go about doing that . When I google it all I get is a million people trying to sell me something. Or give me something pre-packed. -SB Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1252994 Share on other sites More sharing options...
trq Posted August 6, 2011 Share Posted August 6, 2011 Your basically looking for a technique called pagination. We have a tutorial on our site that covers this subject. http://www.phpfreaks.com/tutorial/basic-pagination Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253015 Share on other sites More sharing options...
Zane Posted August 6, 2011 Share Posted August 6, 2011 Your basically looking for a technique called pagination. We have a tutorial on our site that covers this subject. http://www.phpfreaks.com/tutorial/basic-pagination I think what he's talking about is the actual slideshow effect. Where either the pictures move fluidly in a right-to-left motion or it moves upon a mouse event. These types of UI can only be done with, yes, the cursed javascript. Unless of course you make it in Flash or Java. Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253031 Share on other sites More sharing options...
AyKay47 Posted August 6, 2011 Share Posted August 6, 2011 Your basically looking for a technique called pagination. We have a tutorial on our site that covers this subject. http://www.phpfreaks.com/tutorial/basic-pagination I think what he's talking about is the actual slideshow effect. Where either the pictures move fluidly in a right-to-left motion or it moves upon a mouse event. These types of UI can only be done with, yes, the cursed javascript. Unless of course you make it in Flash or Java. the cursed Flash or Java... Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253032 Share on other sites More sharing options...
trq Posted August 6, 2011 Share Posted August 6, 2011 Your basically looking for a technique called pagination. We have a tutorial on our site that covers this subject. http://www.phpfreaks.com/tutorial/basic-pagination I think what he's talking about is the actual slideshow effect. Where either the pictures move fluidly in a right-to-left motion or it moves upon a mouse event. These types of UI can only be done with, yes, the cursed javascript. Unless of course you make it in Flash or Java. I really should stop assuming that everyone knows the difference between what is done server-side and what needs to be done client-side. Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253043 Share on other sites More sharing options...
batstanggt Posted August 6, 2011 Author Share Posted August 6, 2011 OK so whats the verdict is it pagination? Or is it Javascript? I dont really want any swanky effects just the ability to click a left and right arrows underneath an image and then have the image be change obviously according to the clicks. However I do want to get the image from a database not just written into the code. The more i write/ read about it the more it seems like ill have to use a server side (php) and client side ( i guess javascript or jquery) script. Is this correct? -SB Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253053 Share on other sites More sharing options...
trq Posted August 6, 2011 Share Posted August 6, 2011 If the list of images you want is in a database then your definitely going to need to use a server side language such as php. Doing this in php lone means however that every click would refresh the entire page. The other option is to use PHP combined with JavaScript to create an Ajax driven slideshow. For this, you have client side code that when a user clicks next makes a background request back to the server, php then looks up the next image and send this data back to JavaScript. The other option of course is to simply dump all your data into a JavaScript array when the page is created (by PHP) and then use JavaScript to do the entire thing. None of these options are particularly difficult if you know the technologies involved. Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253055 Share on other sites More sharing options...
amg182 Posted August 6, 2011 Share Posted August 6, 2011 Are you images in the database as BLOB or file name? Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253159 Share on other sites More sharing options...
zavaboy Posted August 6, 2011 Share Posted August 6, 2011 If the list of images you want is in a database then your definitely going to need to use a server side language such as php. Doing this in php lone means however that every click would refresh the entire page. The other option is to use PHP combined with JavaScript to create an Ajax driven slideshow. For this, you have client side code that when a user clicks next makes a background request back to the server, php then looks up the next image and send this data back to JavaScript. The other option of course is to simply dump all your data into a JavaScript array when the page is created (by PHP) and then use JavaScript to do the entire thing. None of these options are particularly difficult if you know the technologies involved. Or you can use an IFrame to display the images... but I personally think IFrames suck. Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253161 Share on other sites More sharing options...
voip03 Posted August 6, 2011 Share Posted August 6, 2011 jQuery is the one you need. for the slideshow you will have good time with jquery. just google it ' jquery slidshow tutorials' and have fun. Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253165 Share on other sites More sharing options...
batstanggt Posted August 6, 2011 Author Share Posted August 6, 2011 I dont yet have the table with the images in the database yet. But just so i know once I get to that point (BLOB or filename) which should I use or should i say how do i know when to use each? What is BLOB anyways Ive seen this term used quite frequently in my research. -SB Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253277 Share on other sites More sharing options...
amg182 Posted August 6, 2011 Share Posted August 6, 2011 There are two commonly used ways you can store images in a database either using BLOB- having the actual binary file stored within the table, or just having the filename of the image within the table(i.e. image123.jpg) Storing a BLOB is quite a nuisance because it can take up lots of space in your database, is quite slow and is typically frowned upon by webhosting companies. However by storing the image filename in the database table you can refer to the name of the image in your php file which wil then get the image from whatever directory it is stored in.(Much faster and effiecent) I would suggest using javascript and php as i found this to be the easiest and most effient way to place images within a slideshow. Have you got a script yet? Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253299 Share on other sites More sharing options...
batstanggt Posted August 6, 2011 Author Share Posted August 6, 2011 I think I'm going to use BLOB. It suits my application much better. AMG thanks for your help. No I dont have a script yet because I have yet to decide which client side script I am going to use. Do you perhaps know of a good reliable javascript to use as a starting point? I only say javascript specifically because it sounds like youve done this before. -SB Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253308 Share on other sites More sharing options...
amg182 Posted August 6, 2011 Share Posted August 6, 2011 Yeah, I have done something quite similar to this before. Slideshow with Play and pause button etc... It was created in javascript. More than happy to supply you the script if you need. Although I think i had problems using it with BLOB's but I'm sure there is a way around it. I just prefer to store images in the directory. Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253346 Share on other sites More sharing options...
batstanggt Posted August 7, 2011 Author Share Posted August 7, 2011 Thanks amg182 for sticking with this thread and helping me out. If you would be so kind as to supply me the script that would be tremendous. I mean who knows I may get halfway into the BLOB thing and change my mind in which case it would be even better (call it...contingency planning) hahah. Also to at least i know im starting with something that works and as you suggested i may be able to find a way (probably with the help of you guys) to make it work with BLOBs thanks again. -SB Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253564 Share on other sites More sharing options...
amg182 Posted August 7, 2011 Share Posted August 7, 2011 Yeah sure here you go. I have placed the images in a table: <table> <tr> <td><a href="wpimages/<?php echo $row["Image1"]; ?>" target="_self" rel="wplightbox[a]~#~~#~"><img src='wpimages/<?php echo $row["Image1"]; ?>'width="170" height="130"></a></td> <td><a href="wpimages/<?php echo $row["Image2"]; ?>" target="_self" rel="wplightbox[a]~#~~#~"><img src='wpimages/<?php echo $row["Image2"]; ?>'width="170" height="130"></a></td> <td><a href="wpimages/<?php echo $row["Image4"]; ?>" target="_self" rel="wplightbox[a]~#~~#~"><img src='wpimages/<?php echo $row["Image4"]; ?>'width="170" height="130"></a></td> </tr> </table> You will need to paste this javascript into your page: <script type="text/javascript" src="wpscripts/jsFlashVer.js"></script> <script type="text/javascript" src="wpscripts/jquery.js"></script> <script type="text/javascript" src="wpscripts/jquery.wplightbox.js"></script> <style type="text/css"> body {margin: 0px; padding: 0px;} </style> <script type="text/javascript" src="wpscripts/jspngfix.js"></script> <script type="text/javascript"> var blankSrc = "wpscripts/blank.gif"; </script> <script type="text/javascript"> $(document).ready(function() { $('a[rel*=wplightbox]').wplightbox({ strImgDir: 'wpimages/', strScriptDir: 'wpscripts/', nButtonType: 2, nBorderType: 6 }); }) </script> There are also some external javascript files you willl need to place inside a folder. If you PM me your email i will forward them to you. Quote Link to comment https://forums.phpfreaks.com/topic/243994-slideshow-style-image-display/#findComment-1253748 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.