abc

Share This blog with your friends, so that we can improve more & more . our aim is to easy & simple way of learning.

6/10/2018

use of MYSQL in PHP

HI,
main point in this session:
1. insert data
2. create data
3. select data
4. update data
5. delete data

1. insert data
<?php
$servername = "localhost";
$username = "abcd";
$password = "blank";
$dbname = "sample";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$sql = "INSERT INTO hello(firstname, lastname, email)
VALUES ('mayur', 'kumar', 'kumar@kumar.com')";

if (mysqli_query($conn, $sql)) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}

mysqli_close($conn);
?>

in the above example shows that mysqli connection pass & insert data into hello table of sample database.
if record inserted then show message about record inserted sucessfully.
remaining point we discuss in next session

1 comment:

An Introduction to the Laravel Framework: What It Is and Why You Should Use It

  If you're a PHP developer looking for a modern, efficient, and powerful framework to build web applications, look no further than Lara...