set up XAMPP

PHP and MySQL 

XAMPP Down Load Link  Version 7.2.  Click Here

Create a folder within the htdocs folder as in example below which will store your php programs


Download Notepad++ or an Editor of your choice


Connect to MySQL and Create a Database  

View Screen Cast For Help Click Here

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";

// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
   die("Connection failed: " . $conn->connect_error);
}

// Create database
$sql = "CREATE DATABASE mynewDB";
     if ($conn->query($sql) === TRUE) {
        echo "Database created successfully";
   } else  {
      echo "Error creating database: " . $conn->error;
   }

$conn->close();
?> 


Create a Table with the Data Base

Need help View Screen Cast For Help Click Here

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mynewDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

// sql to create table
$sql = "CREATE TABLE MyGuests (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
reg_date TIMESTAMP
)";

if ($conn->query($sql) === TRUE) {
echo "Table MyGuests created successfully";
} else {
echo "Error creating table: " . $conn->error;
}

$conn->close();
?>


Create an entry in the Table 

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mynewDB";


// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO myguests (firstname, lastname, email)
VALUES ('John', 'Doe', 'john@example.com')";

if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

PHP and MySQL 

XAMPP Down Load Link  Version 7.2.  Click Here

Create a folder within the htdocs folder as in example below which will store your php programs


Download Notepad++ or an Editor of your choice


Connect to MySQL and Create a Database  

View Screen Cast For Help Click Here

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";

// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
   die("Connection failed: " . $conn->connect_error);
}

// Create database
$sql = "CREATE DATABASE mynewDB";
     if ($conn->query($sql) === TRUE) {
        echo "Database created successfully";
   } else  {
      echo "Error creating database: " . $conn->error;
   }

$conn->close();
?> 


Create a Table with the Data Base

Need help View Screen Cast For Help Click Here

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mynewDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

// sql to create table
$sql = "CREATE TABLE MyGuests (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
reg_date TIMESTAMP
)";

if ($conn->query($sql) === TRUE) {
echo "Table MyGuests created successfully";
} else {
echo "Error creating table: " . $conn->error;
}

$conn->close();
?>


Create an entry in the Table 

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mynewDB";


// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO myguests (firstname, lastname, email)
VALUES ('John', 'Doe', 'john@example.com')";

if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

PHP and MySQL 

XAMPP Down Load Link  Version 7.2.  Click Here

Create a folder within the htdocs folder as in example below which will store your php programs


Download Notepad++ or an Editor of your choice


Connect to MySQL and Create a Database  

View Screen Cast For Help Click Here

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";

// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
   die("Connection failed: " . $conn->connect_error);
}

// Create database
$sql = "CREATE DATABASE mynewDB";
     if ($conn->query($sql) === TRUE) {
        echo "Database created successfully";
   } else  {
      echo "Error creating database: " . $conn->error;
   }

$conn->close();
?> 


Create a Table with the Data Base

Need help View Screen Cast For Help Click Here

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mynewDB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

// sql to create table
$sql = "CREATE TABLE MyGuests (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
firstname VARCHAR(30) NOT NULL,
lastname VARCHAR(30) NOT NULL,
email VARCHAR(50),
reg_date TIMESTAMP
)";

if ($conn->query($sql) === TRUE) {
echo "Table MyGuests created successfully";
} else {
echo "Error creating table: " . $conn->error;
}

$conn->close();
?>


Create an entry in the Table 

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "mynewDB";


// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "INSERT INTO myguests (firstname, lastname, email)
VALUES ('John', 'Doe', 'john@example.com')";

if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>

Scroll to Top