Jump to content
yakking

Newbie question (really newbie lol)

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

A database isn't just an alternative content holder. It also gives you the ability to search and sort.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.