tomjones Posted July 17, 2006 Share Posted July 17, 2006 Hi,I would like to know how to generate pages such as www.domain.com/file.php?12345 or www.domain.com/file.php?678910.Any advice or links appreciated. Thank you. Link to comment https://forums.phpfreaks.com/topic/14886-generating-pages-with-custom-strings-as-urls/ Share on other sites More sharing options...
redarrow Posted July 17, 2006 Share Posted July 17, 2006 look at $_GET[' '] ok.test.php<?echo"<a href='test_result.php?php=freaks'>go to page</a>";?>test_result.php<?if(!$_GET['php']=='freaks') {do somthink}?> Link to comment https://forums.phpfreaks.com/topic/14886-generating-pages-with-custom-strings-as-urls/#findComment-59645 Share on other sites More sharing options...
tomjones Posted July 17, 2006 Author Share Posted July 17, 2006 I did not see the correlation when experimenting with the above example. More specific I am trying to generate pages with custom names from an array, like www.domain.com/page.php?foo1 and www.domain.com/page.php?foo2. I Just need to know how to create these urls with php.. thanks. Link to comment https://forums.phpfreaks.com/topic/14886-generating-pages-with-custom-strings-as-urls/#findComment-59658 Share on other sites More sharing options...
tomfmason Posted July 17, 2006 Share Posted July 17, 2006 may be a switch statement is what you are wanting.[code=php:0]<?phpfunction getpage($showpage) { switch ($showpage) { case "your_page"://put the php here break; case "your_next_page"://put another page here break; default://your default page }}getpage($_GET['showpage']);//you need this to execute your code?>[/code]A link for this would be whatever.php?showpage=your_pageHope that helpsTom Link to comment https://forums.phpfreaks.com/topic/14886-generating-pages-with-custom-strings-as-urls/#findComment-59662 Share on other sites More sharing options...
pixy Posted July 17, 2006 Share Posted July 17, 2006 ^ It's exactly what redarrow said.You use the $_GET superglobal to track what link to go to. Example:if (isset($_GET['link'])) { $link = $_GET['link']; if ($link == 3) { // Include links for page.php?link=3 } elseif ($link == 5) { // page.php?link=5 } else { die ('You are not using a valid link'); }}else { // Show page.php}You can repeat the elseif statement for however many you want different stuff to show up. There are many ways of using the $_GET superglobal to create those kinds of links. Link to comment https://forums.phpfreaks.com/topic/14886-generating-pages-with-custom-strings-as-urls/#findComment-59663 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.