1

This is a theory question mainly. I am a relatively novice programmer with some skills in PHP/Javascript/C#/Python with ample knowledge of HTML/CSS. I am creating a website that reads information from a database and posts in on a page. However, the data from the database is going to be constantly added to and changed. One of the features of the site is something along the lines of an "upvote system", similar to Reddit or on here. Because the contents of the website will not be static, I am wondering what would (generally speaking) be the best, fastest, easiest, and/or most efficient way to do this? Perhaps some way to procedurally generate and display data using a while loop?

One specific question that I have is: would it be better to open and close an SQL connection for each item, or preload all of the data at the beginning and then display it one by one?

I do not need the code written out for me, just somewhere that I can start and look into to learn myself. Thanks!

EDIT: Just to clarify, I do not need the page to be updated realtime, just on load and reload

THENATHE
  • 11
  • 2

1 Answers1

0

Probably opening and closing a new connection for each new query would not be the best approach. I believe it would consume more resources instead of simply opening a connection retrieving all data, closing the connection, and then simply rendering on the screen. Big frameworks, like Laravel, work like this. You can get more information here.

Jonas Elan
  • 171
  • 1
  • 5