/    Sign up×
Community /Pin to ProfileBookmark

Split page into 2, but file name remains index

Hi, this is my products page: [url]http://netzeye.com/Accessories/index.php[/url]

I’d like split this page into 2 because the images are taking too long to load. In php, i see some websites that have urls after index like index.php?id=1 or something like that and then id=2 could be the 2nd page. I’m not quite sure what the correct term for this is though… But anyways, can anyone please tell me how to do this?

Thanks!

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@Mr__E__CrypticJul 23.2008 — urls like index.php?id=1 send the variable 1 in the url.

Tou can call this ID from PHP by using something like

$id = strip_tags(addslashes($_GET['id']));

this will assign the ID (1) to the var $id, you can then use this to decide what happens on the page, a simple example would be to split the content of your site to two pages and save them as page1.php and page2.php then replace the content (on the original page) with:

[code=php]<?php

$id = strip_tags(addslashes($_GET['id']));

//use a default page if the ID isn't set
if( (!isset($_GET['id'])) or (empty($_GET['id'])) )
{
include('page1.php');
}
else
{
include('page' . $id . '.php');
}

?>[/code]


You'd really want to add more error-checking and handling to it, but might give you an idea where to go.
Copy linkTweet thisAlerts:
@netzeyeauthorJul 23.2008 — Thanks! I'm going to have a go at this right now... Hey by the way, do you have any instant messaging program where i can contact you? It's faster than replying on forums ?
Copy linkTweet thisAlerts:
@netzeyeauthorJul 23.2008 — Right now, I have split my index.php page where it had like 70 products into 7 pages, named consecutively from index1.php to index7.php, with the index.php page having only the code you gave me above.

I have a question though. Do the index1 to index7.php have assigned id's already? I'm confused on this as well as how the transition works from id to id
Copy linkTweet thisAlerts:
@Mr__E__CrypticJul 23.2008 — No, they don't, and they don't need them.

this line:

$id = strip_tags(addslashes($_GET['id']));

gets the vale of id from page.php?id= and stores it as $id so if you'd used page.php?id=1 then $id would equal 1, if you'de used page.php?id=somethingElse then $id would equal somethingElse.

what you're actally saying in the follwoing line:

include('page' . $id . '.php');

is

include('page[B]theValueof$id[/B].php');

so, if you link to mypage.php?id=1, then that line would be saying:

include('page1.php');

if you link to mypage.php?id=2, then that line would be saying:

include('page2.php');

etc etc.

Incidently, you don't need to duplicate all page elements for each index.php you have.

you can use the normal page format and insert the php like below:

[code=html]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php

$id = strip_tags(addslashes($_GET['id']));

//use a default page if the ID isn't set
if( (!isset($_GET['id'])) or (empty($_GET['id'])) )
{
include('page1.php');
}
else
{
include('page' . $id . '.php');
}

?>
</body>
</html>[/code]


and then each index1.php, index2.php etc only needs to contain the code you'd normall have in the body.
Copy linkTweet thisAlerts:
@netzeyeauthorJul 23.2008 — Ok. So in my index.php page, i would have my normal layout, and insert the code below, then for my index1 to index7.php, i would only have the things from my content area?


[code=html]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php

$id = strip_tags(addslashes($_GET['id']));

//use a default page if the ID isn't set
if( (!isset($_GET['id'])) or (empty($_GET['id'])) )
{
include('page1.php');
}
else
{
include('page' . $id . '.php');
}

?>
</body>
</html>[/code]

[/quote]
Copy linkTweet thisAlerts:
@netzeyeauthorJul 23.2008 — Ok i sort of got it to work now, here is the link: http://www.netzeye.com/test/index.php?id=1 (that's my http://www.netzeye.com/test/page1.php), but when i change id to 2, which is my http://www.netzeye.com/test/page2.php, the layout messes up. I made sure that all that is in my page2.php are the things in my content area, no layout, but it's showing my layout as well.
Copy linkTweet thisAlerts:
@netzeyeauthorJul 23.2008 — Ok it works now lol, thanks for the codes!

http://www.netzeye.com/test/index.php

I have a page selection thing at the bottom so visitors can get quick access to the diff pages. Is there a quick way to do this, or would i have to type out the whole html code ex:

Pages: <a href="http://">1</a> <a href="http://">2</a>[/quote]
Copy linkTweet thisAlerts:
@Mr__E__CrypticJul 23.2008 — Typing it out's probably easiest since it's only 7 pages. Incidently, there's something up with the first page (the About Us/Terms & Conditions/Contact Us are being pushed out of place). Other pages are fine though.
Copy linkTweet thisAlerts:
@netzeyeauthorJul 23.2008 — Typing it out's probably easiest since it's only 7 pages. Incidently, there's something up with the first page (the About Us/Terms & Conditions/Contact Us are being pushed out of place). Other pages are fine though.[/QUOTE]


Thx for pointing it out!
Copy linkTweet thisAlerts:
@netzeyeauthorJul 23.2008 — nevermind?
Copy linkTweet thisAlerts:
@Mr__E__CrypticJul 23.2008 — huh? what? who? where? what happened?
×

Success!

Help @netzeye spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...