Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

First, apologies in advance if this is in the wrong place - I wasn\'t sure if it

ID: 647144 • Letter: F

Question

First, apologies in advance if this is in the wrong place - I wasn't sure if it should be here or in Code Review, but as I'm not actually asking for anyone to review my code . . .

Here's my project: Mostly as a learning exercise I am writing my own blog engine. Here's how it works:

Admin writes post - > post is saved to .html file, and details of post are written BOTH to a MySQL database and a JSON file using PHP - > posts are loaded onto site via iframes, determined by JavaScript using the details in the JSON file.

Thus for loading posts onto the site, no PHP or access to the database is required. The only reason for the database at all is to have an editable record so that if the admin needs to delete a post, the entry can be removed from the database and the JSON file re-written from the database.

What I want to know: 1) This seems a bit cumbersome. Would people recommend doing away with the JSON and making more use of the database? How do I integrate this with JavaScript stuff? 2) Is storing each post as a separate .html file and loading as an iframe a reasonable way of doing things? 3) Is there any way to cut out the PHP entirely? I am not keen on it really. I am starting to learn Python, but it seems an awful palaver for a small blog engine.

As you can probably tell, I am VERY new to programming! I have looked into TaffyDB, which in theory could get rid of the database entirely - I load the JSON with Taffy, remove one record, and re-write the JSON . . . except I'd still need PHP to write to file I think? Also, I am worried that relying entirely on JSON files will make things very slow (I understand speed issues increase exponentially with JSON size?)

Explanation / Answer

You are overcomplicating things.

The best advice I can give for this is to not be afraid of relying on the database. They exist for the very purpose of managing information. For the vast number of applications, you will not notice a difference between access times when the data is pulled from the file system and when it comes from a database.

Regading iframes, there's no reason to use them here. Either generate the page in its entirety, or use Ajax to insert html where you want it. Among the many problems with iframes is that you cant bookmark them.