-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumber7.php
More file actions
38 lines (34 loc) · 996 Bytes
/
Number7.php
File metadata and controls
38 lines (34 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
ini_set ('error_reporting', 1); //Turns on error reporting - remove once everything works.
try{
require_once('/pdo_connect.php'); //Connect to the database which is outside public_html
$sql = 'SELECT m1.Title AS Movie1, m2.Title AS Movie2 FROM Movie m1 JOIN Movie m2 WHERE m1.Year = m2.Year AND m1.MovieID < m2.MovieID;';
$result = $dbc-> query($sql);
} catch (PDOException $e){
echo $e->getMessage();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>A self-join to find movies that were released in the same year </title>
<meta charset ="utf-8">
</head>
<body>
<h2>A self-join to find movies that were released in the same year </h2>
<table>
<tr>
<th>Movie1</th>
<th>Movie2</th>
<th>Year</th>
</tr>
<?php foreach ($result as $auth) {
echo "<tr>";
echo "<td>".$auth['Movie1']."</td>";
echo "<td>".$auth['Movie2']."</td>";
echo "<td>".$auth['Year']."</td>";
}
?>
</table>
</body>
</html>