DEV Community

Zoya Muskaan
Zoya Muskaan

Posted on Originally published at technology2736.wordpress.com

HTML Can’t Talk to a Database on Its Own

When we built our holiday planner in uni, we had a simple plan. HTML for the pages, SQL for the data. Connect the two and done.

It took us days to realize it doesn’t work like that.

Here’s what nobody told us. HTML can’t talk to a database. A webpage only shows things. It can’t ask a database for anything. There has to be something in the middle that takes the request, asks the database, and sends the answer back to the page.

We didn’t know that. So we kept trying to connect them directly, and nothing worked. No mentor, no one to ask, just us and Google. We searched, tried things, broke things, and tried again.

That “something in the middle” is a backend. In projects like this, it’s usually a bit of server-side code (PHP, Node.js, or Java) that connects to the database, runs the query, and sends the result back to the page.

Now I think of it as three steps:

  1. The user clicks something on the page.
  2. The backend takes that request and asks the database.
  3. The answer comes back and the page shows it.

That’s it. Simple, but it took us days to see it.

If you’re building your first project and stuck on this, you’re not slow. This is one of those things that is hard only until someone says it out loud.

More stories from my uni days coming soon.

Top comments (0)