Summary
1. Creating Database and table with data
2. Create connection with database
3. Install & configure wamp/xamp server to to run php script
4. Showing api
Note : Install wamp/xampp to run mysql database and localhost( to run
php pages and place all php file in 'c:\wamp\www\' (in case of wamp) ,
c:\xampp\htdocs ( in case of xampp).
STEP - 1 : CREATE DATABASE IN MYSQL - Run the wamp/xampp.
Now, Open your browser and place this line - 'http://localhost/phpmyadmin/' (default password 'root').
Go to New --> click on New --> In ' create database' enter your database name' --> click on create.
Now Click on SQL tab in mysql database and place below code.
DATABASE NAME : country_list
*************************************************************
CREATE TABLE `country_list` (
`id` int(11) NOT NULL,
`countrys` varchar(50) NOT NULL,
`capitals` varchar(50) NOT NULL,
`languages` varchar(50) NOT NULL
)
INSERT INTO `country_list` (`id`, `countrys`, `capitals`, `languages`) VALUES
(1, 'india', 'delhi', 'hindi'),
(2, 'america', 'new york', 'english'),
(3, 'russia', 'moscow', 'russian');
ALTER TABLE `country_list`
ADD PRIMARY KEY (`id`);
*************************************************************
Connection.php
***************************************************
<?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "php topic";
// Create connection
$conn = new mysqli($servername, $username, $password, $database);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
***************************************************
No comments:
Post a Comment