Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

show html file in a portion of the webpage + change URL (with & and =)

10:18 am on Aug 21, 2013 (gmt 0)

New User

joined:Aug 21, 2013
posts: 1
votes: 0


I want to have a webpage with multiple portions (created through tables).

When somebody clicks on a link from menu, the html file belonging to that link/section, should appear in a portion of the webpage, and the URL needs to be changed ( like www.yourwebpage.com/index.php?id=2&id=7 ).

As I have heard, this is possible only with PHP, because the server needs to be queried to show such content in a portion of webpage.
And also, the link can be bookmarked (with use of GET) and accessed afterwards at the desired time.
Do I need that each link from menu be a form that would have GET method?

Can anyone give me a short and simple example of such a PHP script that would lead to this result?
Or is there any more simple language other than PHP for this result?

Thank you in advance!
11:06 am on Aug 21, 2013 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

joined:Apr 9, 2011
votes: 244

There exist languages other than php, but they're not any easier. If any of your content is dynamic-- "created through tables" as you put it-- it has to be done in some language. It can't be static html. Unless, er, you want to code several hundred html pages to cover all possible permutations of requests ;)

Any URL can be bookmarked, including parameters (the part after the ? question mark).

But wait!

Since you're doing all this from scratch, now is also the time to work out what you want your URLs to look like. They don't have to have the conventional boring form


just because those are the parameters. You definitely don't need or want "index.php" in there. But beyond that, you can go to something like


and then behind the scenes you rewrite according to a pattern, like

widget(\d+)/foobar(\d+) >> /index.php?id=$1&page=$7

(Note that you cannot have two different parameters with the same name. I don't know if the duplicate "id=" in your post was a typo.)

Once you've figured out exactly what you want to do, you can then start working out the php. You can't simply copy and paste some generic code. But it isn't hard to get started-- especially since a lot of the page can be perfectly normal, static html. I don't generally approve of the "If I can do it, anyone can" argument. But honestly, if I can make php pages, 98% of the people reading WebmasterWorld forums can do it :)

Then there's Option B, which is to shop around for an existing CMS that will do what you need. Then you don't have to learn anything.
1:35 am on Aug 24, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member Top Contributors Of The Month

joined:July 19, 2013
votes: 0

If I'm understanding correctly, it sounds like you're saying you would like to have people click a link and the content on some portion of the page change without changing the actual page they're viewing?

If that's the case, you'll likely need to use a combination of JavaScript [something along the lines of <a href=javascript:void(function('value_to_send'));>Click Here to Show Info</a> + pushState() within the function() to change the URL and add a fragment identifier + an AJAX request to get the info and change the display]. You can then use PHP to receive the value sent by JS and return the result for the specific info.

To get a visitor back to the same display from a link or bookmark you'll need to check for a hash + the info it contains with JS [location.hash] at the time the page loads and "fire" the same [or similar] function to load/display the correct information at the time a visitor lands.

Note: There's usually 10 different ways to code everything, especially when combining JS and PHP, but this was the first one that came to my mind.
11:27 am on Aug 24, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Dec 13, 2009
votes: 0

If JD_Toim's assumption that you would like part of the page to change, without reloading the page, then for your desire to have the URL change, you will need to use the HTML5 history API.


... I believe this is how Sound Cloud do their really cool "continue playing during navigation" thing.