1

Right now, I have a page using just HTML, CSS, and JS which allows the user to select from various options to get to the resource they are looking for. When they get to this resource, I want the page to load certain <h>, <p>, etc elements. However, there are 50+ different resources, so it would be tedious, difficult to maintain, and probably load slower if I have to insert all of these elements in the initial page or include them as 50+ different individual external html pages.

From what I have researched, my best idea would be using PHP and probably storing these elements in MySQL Server, but I am unsure if this is a good solution. To be clear, I want everything to load on the same page, so that the user does not have to refresh/open a new page.

Hylonomus
  • 13
  • 6
  • Possible duplicate: http://stackoverflow.com/questions/676394/how-to-include-an-html-page-into-another-html-page-without-frame-iframe – Edward May 10 '17 at 14:31
  • I feel this boils down to 'how to AJAX' which is a board topic and requires research at your end, just google AJAX + most likely jQuery which simplifies it quite a bunch – Jenne May 10 '17 at 14:37
  • Look into using combinations of PHPs `glob` and `foreach` loop or keeping the names of files in an array and using `foreach` to loop over them. Inside the loop you can use `require_once` to return the file and if the file has output it will place the content where the `require_once` is – Mic1780 May 10 '17 at 14:37
  • Thanks. After some more research, I realized I had been misled about the idea and meaning of AJAX. This looks to give me the exact kinds of tutorials I need. – Hylonomus May 10 '17 at 14:48

2 Answers2

0

Look in to json and jquery to dynamically load the content using php (PDO) (or whatever) as the go between for accessing the database. You have a long road ahead of you though and there are quite a bit of security considerations you'll need to address.

Binxalot
  • 41
  • 7
0

So, it turns out this is exactly what AJAX stands for and is used for. Good resource for PHP here: https://www.w3schools.com/xml/ajax_php.asp

Hylonomus
  • 13
  • 6