- 1). Create a database. Using any of the popular database-management systems, such as Oracle or MySQL, add a new database according to the procedure for your database-management system. Most database-management systems offer both a command-line interface (typically based on the structured query language or SQL) and a graphical user interface. If you are new to databases, the graphical user interface may be easier to start out with.
- 2). Store website data in the database. Add a table to your database and insert records containing the data you'll display on your website. The table is a logical structure within the database that stores records that contain the actual data and have one or more fields (or data items) associated with them.
- 3). Write a PHP software module to access your database and retrieve the stored website data. Software is written, or coded, by typing the software instructions into an editing program such as Notepad. The PHP software module will be executed by your website hosting service computer. The PHP module will connect to your database and then send requests (typically in the form SQL commands) to retrieve stored data. After the data is retrieved, the PHP module will need to format the data for display on a web page and transfer the formatted data to the user's web browser for display as part of a website page. Sample PHP code for a database-driven website can be found on MySQL.com.
- 4). Design a website page that connects with your PHP module. Using a text editor or HTML editor, write the HTML code for a website page that will connect to your PHP module. The website page, when being requested by a browser of a site visitor, will automatically execute the PHP software, which will then retrieve the data from the database and send it along to the visitor's browser. The HTML code will need to include the name of the PHP function and will also need to pass (or transfer) a value (called a parameter) to the PHP module telling the module what data to retrieve. For example, an online shoe store may have a website page that passes a shoe style number to the PHP module so that the PHP module will retrieve the data from the database corresponding to that particular shoe style number.
- 5). Test your website. To do so, transfer your PHP module, website pages and database to your website hosting service. Then, access your website as a visitor would and verify that your website pages are displaying the correct data. Note any problems and make any necessary changes.
previous post
next post