Källkod
Följande filer och mappar finns under mappen webbserverprogrammering.
Mappar visas till vänster och filer till höger. Klicka på en fil eller mapp för att öppna nedan eller visa dess innehåll.
webbserverprogrammering/exercises/mysql/exercise_1/
10 filer
back_button.php
create_table.php
dbconnection.php
delete_row.php
delete_table.php
index.php
insert_default_values.php
insert_values.php
print_table.php
update_values.php
create_table.php
dbconnection.php
delete_row.php
delete_table.php
index.php
insert_default_values.php
insert_values.php
print_table.php
update_values.php
insert_default_values.php
33 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="sv">
<head>
<title>Infoga standardvärden</title>
<meta charset="utf-8">
</head>
<body>
<?php
include('back_button.php');
include ('dbconnection.php');
try {
# sql
$sql = "INSERT INTO kompisar (firstname, lastname, mobile, email) VALUES (?, ?, ?, ?)";
# prepare
$stmt = $dbconn->prepare($sql);
$stmt->execute(['KompisEtt', 'AlltsåFörsta', "070 123 45 67", "första@gmail.com"]);
$stmt->execute(['KompisTvå', 'AlltsåAndra', "073 141 59 26", "andra@outlook.com"]);
$stmt->execute(['KompisTre', 'AlltsåTredje', "076 765 43 21", "tredje@yahoo.com"]);
$stmt->execute(['KompisFyra', 'AlltsåFjärde', "070 123 45 67", "fjärde@icloud.com"]);
echo "Standardvärden lades till.";
}
catch(PDOException $e)
{
echo "<hr>" . $sql . "<hr>" . $e->getMessage() . "<hr>";
}
$dbconn = null;
?>
</body>
</html>