-
Notifications
You must be signed in to change notification settings - Fork 0
/
Show_A.php
executable file
·149 lines (132 loc) · 3.57 KB
/
Show_A.php
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
include 'Helpers.php';
function actorInformation($identifier) {
if ($identifier) {
$query = "SELECT * FROM Actor WHERE id = " . $identifier . ';';
$queryResult = runQuery($query);
if ($queryResult === "failed") {
return "failed";
}
$queryRows = getAllRows($queryResult);
if (count($queryRows) < 1) {
return array();
}
$queryRow = $queryRows[0];
$actorInformation = array(
"name" => $queryRow["first"] . " " . $queryRow["last"],
"sex" => $queryRow["sex"],
"dob" => $queryRow["dob"],
"dod" => $queryRow["dod"],
);
$queryResult->free();
return $actorInformation;
}
return array();
}
function movieRoleInformation($identifier) {
if ($identifier) {
$query =
"SELECT * FROM MovieActor MA, Movie M WHERE MA.mid = M.id AND" .
" MA.aid = " . $identifier . ";";
$queryResult = runQuery($query);
if ($queryResult === "failed") {
return "failed";
}
$queryRows = getAllRows($queryResult);
$queryResult->free();
$movieRoleInformation = array();
foreach ($queryRows as $movieRole) {
$movieRoleInformation[$movieRole["mid"]] = array(
"role" => $movieRole["role"],
"title" => $movieRole["title"],
);
}
return $movieRoleInformation;
}
return array();
}
$actorInformation = actorInformation($_GET["identifier"]);
$movieRoleInformation = movieRoleInformation($_GET["identifier"]);
?>
<html>
<head>
<?php $title = "IMDB: I(ncomplete and Dated) Movie DB" ?>
<title><?php print "$title"; ?></title>
<link rel="stylesheet" type="text/css" href="./style.css">
</head>
<body bgcolor=white>
<a href="search.php"><h1><?php print "$title"; ?></h1></a>
<nav>
<a href="./search.php">Search</a>
<a href="./Add_A_or_D.php">Add Actor or Director</a>
<a href="./Add_M.php">Add Movie</a>
<a href="./Add_A_M_relation.php">Add Actor/Movie Relation</a>
<a href="./Add_D_M_relation.php">Add Director/Movie Relation</a>
</nav>
<div class="content">
<hr>
<?php
if ($actorInformation === "failed") {
print '<h2>Invalid Identifier</h2>';
} else if (!empty($actorInformation)) {
?>
<h2>Actor Information:</h2>
<table border="1" cellpadding="2" cellspacing="1">
<thead>
<tr>
<td>Name</td>
<td>Sex</td>
<td>Date of Birth</td>
<td>Date of Death</td>
</tr>
</thead>
<tbody>
<tr>
<?php
foreach($actorInformation as $info) {
print '<td>';
print $info;
print '</td>';
}
?>
</tr>
</tbody>
</table>
<?php } ?>
<?php
if ($movieRoleInformation === "failed") {
} else if (!empty($movieRoleInformation)) {
?>
<h2>Actor's Movies and Role:</h2>
<table border="1" cellpadding="2" cellspacing="1">
<thead>
<tr>
<td>Role</td>
<td>Movie Title</td>
</tr>
</thead>
<tbody>
<?php
foreach($movieRoleInformation as $mid => $row) {
print '<tr>';
foreach ($row as $info) {
print '<td>';
print "<a href='Show_M.php?identifier=$mid'>";
print $info;
print '</a>';
print '</td>';
}
print '</tr>';
}
?>
</tbody>
</table>
<?php } ?>
<h2>Search Actors and Movies</h2>
<form action="./search.php" method="GET">
<input type="text" name="query" size="40" <br>
<input type="submit" value="Submit">
</form>
</div>
</body>
</html>