connect_error) { die("Connection failed: " . $conn->connect_error); } // Display Member table echo "

Member Table

"; $result = $conn->query("SELECT * FROM Member"); echo ""; echo ""; while($row = $result->fetch_assoc()) { echo ""; } echo "
MemberIDMemberNameMemberEmail
" . $row["MemberID"]. "" . $row["MemberName"]. "" . $row["MemberEmail"]. "
"; // Display Group table echo "

Group Table

"; $result = $conn->query("SELECT * FROM `Group`"); echo ""; echo ""; while($row = $result->fetch_assoc()) { echo ""; } echo "
GroupIDGroupNameGroupDescription
" . $row["GroupID"]. "" . $row["GroupName"]. "" . $row["GroupDescription"]. "
"; // Display MemberGroup table echo "

MemberGroup Table

"; $result = $conn->query("SELECT * FROM MemberGroup"); echo ""; echo ""; while($row = $result->fetch_assoc()) { echo ""; } echo "
MemberIDGroupIDJoiningDate
" . $row["MemberID"]. "" . $row["GroupID"]. "" . $row["JoiningDate"]. "
"; // Form to add a row to Member table echo "

Add a Member

"; echo "
Name:
Email:
"; // Form to modify a row in MemberGroup table echo "

Modify MemberGroup

"; echo "
MemberID:
GroupID:
Joining Date:
"; // Form to delete a row from Group table echo "

Delete a Group

"; echo "
GroupID:
"; // Process form submissions if ($_SERVER["REQUEST_METHOD"] == "POST") { if (isset($_POST['add_member'])) { $name = $_POST['name']; $email = $_POST['email']; $sql = "INSERT INTO Member (MemberName, MemberEmail) VALUES ('$name', '$email')"; $conn->query($sql); header("Refresh:0"); } if (isset($_POST['modify_membergroup'])) { $member_id = $_POST['member_id']; $group_id = $_POST['group_id']; $joining_date = $_POST['joining_date']; $sql = "UPDATE MemberGroup SET JoiningDate='$joining_date' WHERE MemberID='$member_id' AND GroupID='$group_id'"; $conn->query($sql); header("Refresh:0"); } if (isset($_POST['delete_group'])) { $group_id = $_POST['group_id']; $sql = "DELETE FROM `Group` WHERE GroupID='$group_id'"; $conn->query($sql); header("Refresh:0"); } } // Forms to select queries echo "

Run SELECT Queries

"; echo "
SELECT * FROM Member ORDER BY MemberName
SELECT * FROM Member WHERE MemberName LIKE '%cloud%'
SELECT Member.MemberName, `Group`.GroupName FROM Member INNER JOIN MemberGroup ON Member.MemberID = MemberGroup.MemberID INNER JOIN `Group` ON MemberGroup.GroupID = `Group`.GroupID
SELECT * FROM Member LIMIT 3
SELECT MAX(MemberID) AS MaxMemberID FROM Member
"; // Display query results if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['run_query'])) { $query = $_POST['query']; switch ($query) { case '1': $sql = "SELECT * FROM Member ORDER BY MemberName"; break; case '2': $sql = "SELECT * FROM Member WHERE MemberName LIKE '%cloud machabe%'"; break; case '3': $sql = "SELECT Member.MemberName, `Group`.GroupName FROM Member INNER JOIN MemberGroup ON Member.MemberID = MemberGroup.MemberID INNER JOIN `Group` ON MemberGroup.GroupID = `Group`.GroupID"; break; case '4': $sql = "SELECT * FROM Member LIMIT 3"; break; case '5': $sql = "SELECT MAX(MemberID) AS MaxMemberID FROM Member"; break; default: $sql = ""; } if ($sql) { $result = $conn->query($sql); echo "

Query Results

"; echo ""; while($row = $result->fetch_assoc()) { echo ""; foreach ($row as $cell) { echo ""; } echo ""; } echo "
" . $cell . "
"; } } $conn->close(); ?> iframe src="task1.txt" height="400" width="1200">Your browser does not support iframe.