In here, I am showing you how to use TideSDK to connect MySQL Database with PHP in your applicaion.
Example Data
The example data in this post uses as below.
CREATE TABLE fruits (`id` int, `name` varchar(50));
INSERT INTO fruits (`id`, `name`)
VALUES (1, 'Apple'),
(2, 'Durian'),
(3, 'Banana'),
(4, 'Lemon'),
(5, 'Pear'),
(6, 'Star fruit'),
(7, 'Strawberry'),
(8, 'Orange');
After that we need create a connection string with the Database. Save the code below as
conn.php and put it inside the
Resources folder.
$conn = mysql_connect('localhost', 'username', 'password');
mysql_select_db('foo', $conn);
In here, I am showing you how to use TideSDK to display the phpinfo() and available php extension in your application.
First, use the
TideSDK Developer to create a new application. After that, open the
index.html file and edit the source.
In this example, I use JQuery to call the phpinfo(). So we need include the JQuery as well.
Include the JQuery inside the head.
<head>
<script src="jquery-2.0.1.min.js"></script>
</head>
We need include another PHP class to call the phpinfo() script to display the information. include the PHP file in head as well.
<head>
<script src="jquery-2.0.1.min.js"></script>
<script type="text/php" src="info.php"></script>
</head>