Book Image

Mastering jQuery Mobile

Book Image

Mastering jQuery Mobile

Overview of this book

Table of Contents (17 chapters)
Mastering jQuery Mobile
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

A dab of PHP


Before we start writing any code, let's set up a few simple things:

  1. Let's create a new folder named JQMData in the htdocs folder in our XAMPP folder. Look for your XAMPP folder in your default installation drive on Windows or the Applications directory on Mac, if you have your XAMPP installed at the default location.

  2. Now, copy the index.html file from the previous chapter and paste it into this JQMData folder.

  3. Rename this file from index.html to index.php.

  4. 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...