enchance Posted September 19, 2007 Share Posted September 19, 2007 I'm trying to build a small portfolio and instead of using several HTML pages I wanted to just use PHP. What I have is an array of each image's path (for the "src" attribute). I was thinking when I click "Next" (a text link) it increments the array and once it has reloaded itself it would simply look at the query string then display the new image. I have some questions though: 1. What line do I use which will reload the page with the new incremented variables? 2. When the page reloads itself, will it automatically get the new image to load? I already placed $thisimage = $_GET['imagenumber'] at the very top so it updates the "src" attribute for the image. Thanks in advance. Any help/suggestions would be great, especially with that reloading part. Quote Link to comment https://forums.phpfreaks.com/topic/69975-reloading-the-page-with-updated-query-string-values/ Share on other sites More sharing options...
pocobueno1388 Posted September 19, 2007 Share Posted September 19, 2007 Sounds like your on the right path. 1. What line do I use which will reload the page with the new incremented variables? $thisimage = $_GET['imagenumber'] should be placed above the line where you display the image, as long as you have that, you should be good. 2. When the page reloads itself, will it automatically get the new image to load? Yes, because it will know what array value to pull by taking it from the URL. <?php $images = array("1.jpg", "2.jpg", "3.gif"); $thisimage = (isset($_GET['imagenumber']) ? $_GET['imagenumber'] : 0; echo "<img src='".$images[$thisimage]."'>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/69975-reloading-the-page-with-updated-query-string-values/#findComment-351466 Share on other sites More sharing options...
enchance Posted September 19, 2007 Author Share Posted September 19, 2007 I haven't tested it yet, so you're saying that once I click the link which updates the variables which changes the "src" attrib it will also automatically reload the page? Quote Link to comment https://forums.phpfreaks.com/topic/69975-reloading-the-page-with-updated-query-string-values/#findComment-351474 Share on other sites More sharing options...
pocobueno1388 Posted September 19, 2007 Share Posted September 19, 2007 Well, are you wanting the page to reload without having to refresh the browser? If that is what your after, your going to need AJAX or JavaScript. If it doesn't matter if the page has to refresh, then the method I supplied should work fine. Quote Link to comment https://forums.phpfreaks.com/topic/69975-reloading-the-page-with-updated-query-string-values/#findComment-351500 Share on other sites More sharing options...
enchance Posted September 20, 2007 Author Share Posted September 20, 2007 I just wanted to clarify that point. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/69975-reloading-the-page-with-updated-query-string-values/#findComment-351525 Share on other sites More sharing options...
pocobueno1388 Posted September 20, 2007 Share Posted September 20, 2007 You didn't answer the question... Quote Link to comment https://forums.phpfreaks.com/topic/69975-reloading-the-page-with-updated-query-string-values/#findComment-351529 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.