darkboost Posted January 26, 2010 Share Posted January 26, 2010 I have 2 frames MAIN-PAGE and FOOTER and am only using frames to avoid page refreshes in the FOOTER which has many thumbnails. When the user clicks a thumbnail image I simply want the MAIN-PAGE to refresh with the correct image. Because of the limitations of frames and avoiding making a separate php page for each image I have started looking at cookies which from what I see looks ideal.I have set in index.php : setcookie("id", "1");and then echo this in the MAIN-PAGE and the image loads fine but am now wanting to know if I can and how can I update this cookie when a used clicks a thumbnail?Any assistance or suggestions on other ways to achieve this outcome would be greatly appreciated. Link to comment Share on other sites More sharing options...
jeffman Posted January 26, 2010 Share Posted January 26, 2010 This doesn't answer your question. Personally, I think you're working too hard.1. Images are normally cached by browsers. Even huge ones. Thumbnails should not be a problem. Meaning, after the first page load, your thumbs should load instantly, whether they are in a frame or not. If your user visits the page often enough, they will stay cached, and still load instantly. If load time is your issue, a frame is unneeded.2. If you don't want to hardcode your footer into every page, look into the PHP include statement. It sounds ideal for your application. Link to comment Share on other sites More sharing options...
ProblemHelpPlease Posted January 26, 2010 Share Posted January 26, 2010 Cookies are not really the best way to go in my opinion, you could look at using javascript to change the image src to the correct image. Link to comment Share on other sites More sharing options...
darkboost Posted January 26, 2010 Author Share Posted January 26, 2010 I was originally using the PHP Include feature and loading the image based on the $_GET however it would always reset the the thumbnail scrolling which was very annoying if you had clicked image 350/1200 and then have to keep scrolling etc. I know there are many Javascripts available which write position cookies which sounds even more fullon than what I was simply trying to achieve which is to place the image number in the cookie and load the image from there.Can you update a cookie via a URL like the example below? <?php$update_cookie = cookieset("id", "20");echo '<a href="index.php?id="20" target="main-page" '.$update_cookie.'><img src="../thumb/001.jpg" border="0" /></a>';?> Link to comment Share on other sites More sharing options...
Synook Posted January 27, 2010 Share Posted January 27, 2010 Why not just use AJAX?Edit: the above code doesn't make sense - it will just echo out <a href="index.php?id="20" target="main-page" return value of cookieset()><img src="../thumb/001.jpg" border="0" /></a> Link to comment Share on other sites More sharing options...
darkboost Posted January 27, 2010 Author Share Posted January 27, 2010 I have never used AJAX is this as easy to write in notepad as PHP or do I need to purchase or download 3rd party programs and MySQL database apps etc. ? Link to comment Share on other sites More sharing options...
Synook Posted January 27, 2010 Share Posted January 27, 2010 http://w3schools.com/ajax/ - it is a technique utilising the JavaScript XMLHttpRequest object to make asynchronous requests to the server. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.