Jump to content

Reloading the page with updated query string values


enchance

Recommended Posts

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.

Link to comment
Share on other sites

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]."'>";

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.