Check out example codes for "odp mysql 3wschools". It will help you in understanding the concepts better.

Code Example 1

<?php
$servername = "localhost";
$username = "username";

 $password = "password";

try {
  $conn = new PDO("mysql:host=$servername;dbname=myDB", $username, $password);

    // set the PDO error mode to exception
  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    echo "Connected successfully";
 
} catch(PDOException $e) {
  echo "Connection failed: " . $e->getMessage();
}

?>

Learn ReactJs, React Native from akashmittal.com