A dab of PHP
Before we start writing any code, let's set up a few simple things:
Let's create a new folder named
JQMData
in thehtdocs
folder in ourXAMPP
folder. Look for yourXAMPP
folder in your default installation drive on Windows or the Applications directory on Mac, if you have your XAMPP installed at the default location.Now, copy the
index.html
file from the previous chapter and paste it into thisJQMData
folder.Rename this file from
index.html
toindex.php
.Create a new file and name it
db.php
.
If you have followed the steps correctly, you should see our application when you fire up this URL in your browser: localhost/JQMData
.
We are now ready to write our first PHP code for this application. Open up the db.php
file that we have just created. We have to now establish a connection to the MySQL database that we have created. Let's see how this works. Copy the following code to db.php
file and save it:
<?php $servername = "localhost"; $username = "root"; $password = ""; $dbname...