Quick question, I am working on a project at work and I would like to ask if the following is possible, and some tips to get started on it:
I have a index.html, and 001.html, 002.html, 003.html that get loaded in it with jQuery(.load() technique).
I would like to generate pages with a php file, a backend if you prefer, I would have 98% of the code that stays the same, but some data fetched in the SQL database (image001 for example).
Once that is generated I would like to edit the index.html page to add the page generated in it.
Is this possible ?
Thanks in advance !
(you could also look at the code here: http://www.ca-cest-fait.fr if you want to understand better).
What you are attempting is very not recommended. It is the wrong approach. The correct approach is to
jQuery.load()a.phpfile, which would dynamically generate the correct response, and be included in the page. This saves you the trouble of generating and saving endless pages on the server.It is however, possible. Using
glob()you can find out what current files exist. Usingfopen()andfwrite()you can write a file, or if you like being fancy, you can useDOMto generate the HTML for you.Then, you use the same techniques to edit the
index.htmlfile, to include the newest files.