| Pages: [1] :: one page |
|
|
| Author |
Topic |

4rc4ng3L
Gallente C R Y O
 |
Posted - 2008.04.29 21:04:00 -
[1]
Im currently building a website, using dreamweaver and with PHP, CSS. The site will have to contain a large amount of images, and im curious about how exactly to update them on a page.
Basically i want an image container on a page, that updates when ever the NEXT, PRVIOUS buttons are pressed. Origionally what i had done was to have each image on a seperate page then simply link the next to whatever page was next on the server containing the image. However if i suddenly had 100+ pages and needed to update the pages i would have to do each one individually.
So, i need your help/opinions on other ways to achieve the same effect. What i was thinking was a MySQL database where the NEXT, PREVIOUS buttons simply updated the image container with the appropriate imge from the database. Is this the best idea? Is there anything slightly more simple i could do to get the same result?
I appreciate any help as its the only thing holding me back. ------------------------------------------ - To Jumanji, or not to Jumanji...... - |

Faife
Noctiscion Twilight Trade Cartel
 |
Posted - 2008.04.29 21:36:00 -
[2]
standard way of doing this simply:
images are named in a numeric manner. the url includes a GET variable called "image" or something, then your php has
// various checks that $_GET["image} is a number goes here // then display image print "<img src='" . $_GET["image"] . "'>";
then your previous and next links go to "mypage.php?image=" . $_GET["image"]-1 and "mypage.php?image=" . $_GET["image"]+1 respectively.
notes: make sure you clean your input make sure to handle border cases (ie, dont request image -14 or whatever) if needed, code to insert an image in the middle of a stack of images will have to do a rename on all the other ones. not that big a deal, just dont cause an overwrite condition and nuke all the images
or i guess you can make a database and keep track of image ordering in there as a column to the image field.
|

Faife
Noctiscion Twilight Trade Cartel
 |
Posted - 2008.04.29 21:37:00 -
[3]
you can combine this with mod rewrite to create nice bloggy urls like
gallery/12
if you hate the ?thread=760709 type urls as present up in your address bar currently
|

Riethe
Fine Goods for Fine Gentlemen
 |
Posted - 2008.04.29 21:44:00 -
[4]
Edited by: Riethe on 29/04/2008 21:45:04 edit: if all your images are named numerically like he is suggesting, that could work too and save you a lot of work. As you can see in my example it's a little more flexible if your images do not follow any logical pattern as far as your naming convention.
To be honest, I'm not 100% sure what you're trying to achieve, but let me give it a shot:
What if you stored all the images with an ID in a database, for example: table images
ID + path ------------ 0 + blah/image0.jpg 1 + foo/bar.jpg 2 + eg.jpg
then on your page, you use a $_GET var such as "startfrom" or something of that nature, so your actual url looks something like:
images.php?startfrom=15
then when you're deciding what images to display, you go about it like this:
$sql = "SELECT * FROM `images` LIMIT ".$_GET['startfrom'].",15";
So once this is actually parsed it literally translates to:
SELECT * FROM `images` LIMIT 15,15 Or something of that nature. Also you probably want to make sure 'startfrom' is properly stripped, otherwise you might get some sql injection going on. But you can sort that out separately.
What that query would do is: pull all rows starting from startfrom, which should be an integer, in our case it would be 15. So starting at ID 16, and the second parameter refers to the maximum number of rows to return.
So the end result is 15 images that you can print out in a simple loop:
$sql = "SELECT * FROM `images` LIMIT ".$_GET['startfrom'].",15"; $hurr = mysql_query($sql);
foreach(mysql_fetch_array($hurr) as $row) { echo '<img src="'.$row['path'].'">'; }
Something like that.
Keep in mind this was just written real quick, I don't expect that to work, but it might lead you in the right direction.
Let me know if this helps out any or if you need something elaborated on.
Effectively this will allow you to use ONE single php page to display all of your images effortlessly, with pagination.
Good luck.
|

4rc4ng3L
Gallente C R Y O
 |
Posted - 2008.04.29 22:23:00 -
[5]
Edited by: 4rc4ng3L on 29/04/2008 22:24:25 appreciate the quick replies....
Suppose i should have given more details, basically its a comic/art site, will contain aload of web comics. There will be many different series's each with numourous episodes. So basically once you navigate to the series main page, you can just skip through the episodes using a the NEXT, PREVIOUS buttons, and then clicking either would simply update the image(episode) in the image place holder.
I was origionally using a new web page for each episode so clicking NEXT would simply change to the selected page, but thats a completely unrealistic way of doing it if i ever wanted to update the main template of the site etc.
I'll try the above suggestions anyway, thanks again guys  ------------------------------------------ - To Jumanji, or not to Jumanji...... - |

Riethe
Fine Goods for Fine Gentlemen
 |
Posted - 2008.04.29 23:08:00 -
[6]
You can distinguish between episodes by adding another $_GET variable and another field in your table to identify them by.
Honestly I still don't fully get what needs to be printed out on each page, but with a bit modification of my original example, you should be able to achieve what you're trying here.
If you write a full example of how each element is laid out, how you navigate to each episode, and what is contained in each episode, or even show me the site in its current incarnation, I can write a more detailed response.
Regards
|

4rc4ng3L
Gallente C R Y O
 |
Posted - 2008.04.29 23:55:00 -
[7]
Edited by: 4rc4ng3L on 29/04/2008 23:55:31
Originally by: Riethe You can distinguish between episodes by adding another $_GET variable and another field in your table to identify them by.
Honestly I still don't fully get what needs to be printed out on each page, but with a bit modification of my original example, you should be able to achieve what you're trying here.
If you write a full example of how each element is laid out, how you navigate to each episode, and what is contained in each episode, or even show me the site in its current incarnation, I can write a more detailed response.
Regards
Sure, can see the first basic test template we were using here.
If you navigate to Comics/Define Mistake for example, clicking the right arrow would change the main picture to another, being the next episode. The main test site currently just changes the whole web page to one containing the next episode. Which is what im hoping to change with the help you've given me above.
------------------------------------------ - To Jumanji, or not to Jumanji...... - |

Gemineia
Rakeriku Otaku Invasion
 |
Posted - 2008.04.30 07:53:00 -
[8]
Why not use the glob php function to build up an array of all your images in a set directory. Once you've got that array you can easily turn it into a javascript array.
From there you should be able to use the javascript onclick event to flip from one image to the next without having to reload the page at all. Saves alot of DB queries I should think.
|
|
| Pages: [1] :: one page |
| First page | Previous page | Next page | Last page |