Jump to content

Newbie question (really newbie lol)


yakking

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.