astanford10 Posted January 5, 2011 Share Posted January 5, 2011 Ok so this is what I am looking for and I cannot seem to find any documentation on it! I have some html files which I want to call up by using the following: engine.php?id=? with the questionmark being 1,2,3,4,5,6, etc... where each number is a different HTML page, I just want it to look a little cleaner then if I just have it redirect to each page itself I mean come on what looks better: http://localhost/engine.php?id=1 <------ http://localhost/home.html Any guidance is welcome. Thanks, Drew Quote Link to comment Share on other sites More sharing options...
revraz Posted January 5, 2011 Share Posted January 5, 2011 I don't actually see a question or know quite what you are asking. Without seeing code on what you are doing now and what you want to do, it's hard to answer. Quote Link to comment Share on other sites More sharing options...
Zurev Posted January 5, 2011 Share Posted January 5, 2011 I mean make the .html pages into .php, like 1.php, 2.php, etc. Since you can rename them to php and it won't change how they render. Then make your engine.php: <?php // engine.php $getID = (int)$_GET['id']; if (!isset($_GET['id'])) { die("Invalid ID selected."); } include_once($getID.".php"); ?> Then when you go to engine.php?id=5 it will load 5.php in that page. Quote Link to comment Share on other sites More sharing options...
astanford10 Posted January 5, 2011 Author Share Posted January 5, 2011 I mean make the .html pages into .php, like 1.php, 2.php, etc. Since you can rename them to php and it won't change how they render. Then make your engine.php: <?php // engine.php $getID = (int)$_GET['id']; if (!isset($_GET['id'])) { die("Invalid ID selected."); } include_once($getID.".php"); ?> Then when you go to engine.php?id=5 it will load 5.php in that page. This is close to what I am looking for but I had a engine.php file I wrote 4-5 years back that had something like that but instead of renaming the files to 1.php, 2.php it had a list of file names with IDs and then php would pull from that list and display the file, something like: (Forgot to mention I always change my file extension to .php if that helps.) file.php = ID# then once u input say engine.php?id=ID# it would go to that said page. Quote Link to comment Share on other sites More sharing options...
Zurev Posted January 5, 2011 Share Posted January 5, 2011 <?php // engine.php $filesArray = array( 1 => "home.html", 2 => "contact.html", 3 => "anotherpage.html" ); $getID = (int)$_GET['id']; if (!isset($_GET['id'])) { die("Invalid ID selected."); } include_once($filesArray[$getID]); ?> That would make it so it's http://localhost/engine.php?id=1 and it would choose home.html. How exactly do you want the links to appear? Quote Link to comment Share on other sites More sharing options...
astanford10 Posted January 5, 2011 Author Share Posted January 5, 2011 <?php // engine.php $filesArray = array( 1 => "home.html", 2 => "contact.html", 3 => "anotherpage.html" ); $getID = (int)$_GET['id']; if (!isset($_GET['id'])) { die("Invalid ID selected."); } include_once($filesArray[$getID]); ?> That would make it so it's http://localhost/engine.php?id=1 and it would choose home.html. How exactly do you want the links to appear? Zurev you are my HERO!!! That is exactly what I needed, It is working straight out the doors . Cannot thank you enough although I feel I may be back in the near future lol. BTW can you recommend any good PHP/MySQL learning guides? I am good with HTML just not so much with PHP/MySQL Quote Link to comment Share on other sites More sharing options...
Zurev Posted January 5, 2011 Share Posted January 5, 2011 http://net.tutsplus.com/tutorials/php/learn-php-from-scratch-a-training-regimen/ http://net.tutsplus.com/tutorials/php/everything-you-need-to-get-started-with-mysql/ Both excellent resources. Also, please remember, php.net is your friend. Right in line behind phpfreaks. /endbrownose. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.