how to create a template of webpages using php | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how to create a template of webpages using php

suppose you have to create same kind of webpages multiple times, now instead of making multiple HTML files, can I just use one php file to create multiple no. of pages like that example: suppose a website which shows description about cars. the admin just has to upload some data on some cars. He will just fill up a form made of php and submit it. when the customer comes to the page, he has to enter the model of the car mentioning the company and if the model details are available, the site will show it.

16th Sep 2017, 2:17 PM
Srimanta Mondal
Srimanta Mondal - avatar
1 Answer
+ 1
Content management systems do exactly that if you want to look into it. For example WordPress, Joomla, and others. If you want to create your own, first you need a PHP that creates the needed tables on am existent database where you will store data such as the name of the page, URL, and some more data. Then another PHP which will be the page itself, the other one was something like an installation, however this PHP will consult the database to get the page data, and then "paste" that data un your template. From what I've seen and done myself, it's much easier to first make the html of how the website should look like, then separate it into different files, header in header.php, menu in menu.php and such, then include all those files in a main file, doing so the code ends up so much cleaner. It's easy, but it takes lots of work to do manually.
16th Sep 2017, 4:43 PM
voidneo