-- Practice Final
Aaron Li, Brandon Ong, Aadit Dubey
Problem 1:
Write a PHP program using the msqli OO interface has connects to a Mysql database Business on the default port of localhost, then using a prepared statement inserts a record to an Employee table with schema (ssn, fname, lname, date_of_birth, salary).
$mysqli = new mysqli("localhost", "root", "root", "Business");
$stmt = $mysqli->stmt_init();
if ($stmt->prepare("INSERT INTO Employee VALUES (?, ?, ?, ?, ?)
{
$record_1 = [“123-92-9284”, “bob”, “smith”, “12/02/1999”, 142098];
$record_1 = [“726-92-8732”, “jim”, white”, “04/07/1990”, 89276];
$records = [$record_1, $record_2];
foreach($records as $record) {
$stmt->bind_param("ssssi", $record[0], $record[1], $record[2], $record[3], $record[4]);
$stmt->execute();
}
$stmt->close();
}
$mysqli->close();
(
Edited: 2022-12-05)
<nowiki>
Aaron Li, Brandon Ong, Aadit Dubey
Problem 1:
Write a PHP program using the msqli OO interface has connects to a Mysql database Business on the default port of localhost, then using a prepared statement inserts a record to an Employee table with schema (ssn, fname, lname, date_of_birth, salary).
$mysqli = new mysqli("localhost", "root", "root", "Business");
$stmt = $mysqli->stmt_init();
if ($stmt->prepare("INSERT INTO Employee VALUES (?, ?, ?, ?, ?)
{
$record_1 = [“123-92-9284”, “bob”, “smith”, “12/02/1999”, 142098];
$record_1 = [“726-92-8732”, “jim”, white”, “04/07/1990”, 89276];
$records = [$record_1, $record_2];
foreach($records as $record) {
$stmt->bind_param("ssssi", $record[0], $record[1], $record[2], $record[3], $record[4]);
$stmt->execute();
}
$stmt->close();
}
$mysqli->close();
</nowiki>