yakking Posted August 22, 2015 Share Posted August 22, 2015 OK so I am really new to PHP (really really new lol) I'm making a new plant hobby site, I am not really interested in using scripts like WordPress or the other various blogging sites/scripts. I would like to have all my content in html files (or php files it doesnt really matter) so each page of the site would have its own html file. I would then like to have one file that would be the master page, the page that has all the design content in it, then I could just call up each page simply like www.example.com/plants.php?name=fern or www.example.com/plants.php?name=pine. So when any of those URL's are used it will load the content from the corresponding html file e.g. fern.html or plants.htlm etc. So I've been reading about using PHP includes which I understand how to use, but what I am wanting to do is use a PHP code similar to the <?php echo $_GET["name"]; ?> to grab the "name=" part of the URL that way plants.php looks for the fern.html or plants.html file and includes the content. Am I going about this the right way, or is there a better method? I can bet most people here are laughing at my newbie question, don't blame you really lol Quote Link to comment https://forums.phpfreaks.com/topic/297888-newbie-question-really-newbie-lol/ Share on other sites More sharing options...
scootstah Posted August 22, 2015 Share Posted August 22, 2015 Your idea will work, but it requires that you create a file for every type of plant. The correct approach is to use a database to store your dynamic content, and then you just query the database entry corresponding to the querystring parameter. Quote Link to comment https://forums.phpfreaks.com/topic/297888-newbie-question-really-newbie-lol/#findComment-1519425 Share on other sites More sharing options...
yakking Posted August 23, 2015 Author Share Posted August 23, 2015 Thanks for the reply! I did also look into databases and all the blog software all use a database to store and retrieve the content. The main reason that I wanted to do it the way I suggested was so that I can just create/edit the content from my own PC from simple html files, then just use the include to grab the contents. Is there a specific PHP code I can use for this? Quote Link to comment https://forums.phpfreaks.com/topic/297888-newbie-question-really-newbie-lol/#findComment-1519469 Share on other sites More sharing options...
Barand Posted August 23, 2015 Share Posted August 23, 2015 The main reason that I wanted to do it the way I suggested was so that I can just create/edit the content from my own PC from simple html files, Which you could also do with a form to update the contents of database records Quote Link to comment https://forums.phpfreaks.com/topic/297888-newbie-question-really-newbie-lol/#findComment-1519478 Share on other sites More sharing options...
yakking Posted August 23, 2015 Author Share Posted August 23, 2015 Which you could also do with a form to update the contents of database records Yes this is true. After thinking about it for a bit though I'd still rather try and do it as I mentioned in the OP. I know how to do a PHP include, but I'm still working out how to grab the "name=" part to grab the relevant page? Quote Link to comment https://forums.phpfreaks.com/topic/297888-newbie-question-really-newbie-lol/#findComment-1519491 Share on other sites More sharing options...
Barand Posted August 23, 2015 Share Posted August 23, 2015 A database isn't just an alternative content holder. It also gives you the ability to search and sort. Quote Link to comment https://forums.phpfreaks.com/topic/297888-newbie-question-really-newbie-lol/#findComment-1519493 Share on other sites More sharing options...
CroNiX Posted August 23, 2015 Share Posted August 23, 2015 And databases are highly optimized to quickly store/search/sort/retrieve data. That's their sole purpose. It's the right tool for the job. Coding is also about using the right tool for the job. You will make this a LOT more complex if you do it the way you are wanting to as you will not only have to hand code each html page to enter you data (room for error there) but you also now have to read them in and parse the HTML to get the data back out. That's really a waste and prone to error unless everything is perfect. It also has more wasteful overhead, will take longer and consume more memory than just using a database. Again, a database is the right tool for the job you describe... If you are really new to php this will be a lot more challenging for you to get working, especially the parsing of the HTML, than learning the database stuff. Quote Link to comment https://forums.phpfreaks.com/topic/297888-newbie-question-really-newbie-lol/#findComment-1519496 Share on other sites More sharing options...
yakking Posted August 24, 2015 Author Share Posted August 24, 2015 Thank you for the replies! Can you recommend some good scripts or database managers? Or should I just go down the blog path, or WordPress? Quote Link to comment https://forums.phpfreaks.com/topic/297888-newbie-question-really-newbie-lol/#findComment-1519541 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.