keenlearner Posted December 3, 2006 Share Posted December 3, 2006 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 [url=http://example.com/url_1.php]http://example.com/url_1.php[/url] until [url=http://www.example.com/url_1000.php]http://www.example.com/url_1000.php[/url] . So this is what I had done using switch statement : This is the main page([url=http://www.example.com/main.php]http://www.example.com/main.php[/url]) that contain all the 1000 variable values for the 1000 pages[QUOTE][code=php:0]<?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 1000case "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>[/code][/QUOTE]This is one of the 1000 individual pages, [url=http://www.example.com/url_1000.php]http://www.example.com/url_1000.php[/url][QUOTE]<?php include("http://www.example.com/main.php") ?>[/QUOTE]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 [url=http://www.example.com/url_1000]http://www.example.com/url_1000[/url] as shown above. Any clarification will be much appreciate, Thank you. Link to comment https://forums.phpfreaks.com/topic/29298-dynamic-pages-with-variables/ Share on other sites More sharing options...
trq Posted December 3, 2006 Share Posted December 3, 2006 [quote]My question is, is there a better way than this ?[/quote]Yes! use a database to store your data. All you need do then is lookup the relative data via a variable passed through the url. Link to comment https://forums.phpfreaks.com/topic/29298-dynamic-pages-with-variables/#findComment-134299 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.