$servername = "localhost";
$username = "your_username";
$password = "your_password";
$dbname = "database_name";
$whichTable = "table_name";
try {
# MySQL with PDO_MYSQL
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT * FROM $whichTable WHERE id = :id";
$stmt = $conn->prepare($sql);
$stmt->execute(['id' => $movie__id]);
$row = $stmt->fetch();
$title = $row['movie__title'];
$year = $row['year'];
$rt_score = $row['rt_score'];
}
catch(PDOException $e) {
echo $e->getMessage();
}
$servername = "localhost";
$username = "your_username";
$password = "your_password";
$dbname = "database_name";
$whichTable = "table_name";
try {
# MySQL with PDO_MYSQL
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT SUM(amount) as total_deposits FROM $whichTable";
$stmt = $conn->query($sql);
$results = $stmt->fetch(PDO::FETCH_ASSOC);
$deposits__total = $results['total_deposits'];
}
catch(PDOException $e) {
echo $e->getMessage();
}