Dynamic pages with variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
keenlearner
Forum Commoner
Posts: 50
Joined: Sun Dec 03, 2006 7:19 am

Dynamic pages with variables

Post by keenlearner »

Hello, i am new to php. BTW i am building php website for many pages assume to be 1000 pages with similar design, but different in title, meta description, body content, links. I want every page has its own static url such as http://example.com/url_1.php until http://www.example.com/url_1000.php and avoiding using the dynamic link such as http://www.example.com?url=1 for the sake of search engine friendliness. So this is what I had done using switch statement :

This is the main page(http://www.example.com/main.php) that contain all the 1000 variable values for the 1000 pages

Code: Select all

<?php
$url = (basename($_SERVER['SCRIPT_NAME'])) ;

switch($url){
case "url_1.php" :
$title = " Page 1" ;
$content = " This is the first page with long text..................................." ;
$link = "http://www.example.com/url_1.php" ;
break;

// case goes until 1000

case "url_1000.php" : 
$title = " Page 1000 " ;
$content = " This is the 1000 or the last page with long text.................... " ;
$link = "http://www.example.com/url_1000.php" ;

}

?>

<html>
<head>
<title><?php echo $title ?></title>
</head>

<body>
<p><?php echo $content ?></p>
<a href=<?php echo $link ?> >Home</a>

</body>
</html>


This is one of the 1000 individual pages, http://www.example.com/url_1000.php

Code: Select all

<?php include("http://www.example.com/main.php") ?>
My question is, is there a better way than this ?
How fast will the website be served or php execute the switch statement from the beginning of the case until the last case which is the 1000 or the last if a visitors demand for the url http://www.example.com/url_1000 as shown above. Any clarification will be much appreciate, Thank you.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Re: Dynamic pages with variables

Post by volka »

keenlearner wrote:and avoiding using the dynamic link such as http://www.example.com?url=1 for the sake of search engine friendliness.
Is there a relevant search engine that can't handle http://www.example.com?url=1 ?
keenlearner
Forum Commoner
Posts: 50
Joined: Sun Dec 03, 2006 7:19 am

Post by keenlearner »

I had read some search engine articles, it just that search engine couldn't differentiate if there are the same. Statement from Google webmaster guidelines...
http://www.google.com/support/webmaster ... swer=35769

If you decide to use dynamic pages (i.e., the URL contains a "?" character), be aware that not every search engine spider crawls dynamic pages as well as static pages. It helps to keep the parameters short and the number of them few.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

All the major search engines crawl "dynamic" pages.
keenlearner
Forum Commoner
Posts: 50
Joined: Sun Dec 03, 2006 7:19 am

Post by keenlearner »

If so, how can i goes to the dynamic link way ?
is it like below or any better way ?

<a href="http://www.example.com/main.php?title=p ... ntent=page one description here">Go to page one</a>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Yes, that's the basic concept.. if I understand you correctly.
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

keenlearner
Forum Commoner
Posts: 50
Joined: Sun Dec 03, 2006 7:19 am

Post by keenlearner »

Thank's to all of you....for the helpfulness
Post Reply