OneCompiler

Hslip26

117

Q1]

<!DOCTYPE html> <html> <head> <title>Doctor Visits</title> <style> table { border-collapse: collapse; width: 80%; margin: 20px; }
    th, td {
        border: 1px solid black;
        padding: 10px;
        text-align: left;
    }
</style>
</head> <body> <?php // Assuming you have established a connection to the database
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $hospitalName = $_POST["hospitalName"];

    // Fetch doctors visiting the specified hospital
    $query = "SELECT Doctor.doc_no, Doctor.dname, Doctor.address, Doctor.city, Doctor.area
              FROM Doctor
              JOIN Visits ON Doctor.doc_no = Visits.doc_no
              JOIN Hospital ON Visits.hosp_no = Hospital.hosp_no
              WHERE Hospital.hname = '$hospitalName'";

    $result = mysqli_query($connection, $query);

    if (!$result) {
        die("Query failed: " . mysqli_error($connection));
    }

    // Display the result in tabular format
    echo "<h2>Doctors Visiting $hospitalName</h2>";
    echo "<table>";
    echo "<tr><th>Doctor No</th><th>Doctor Name</th><th>Address</th><th>City</th><th>Area</th></tr>";

    while ($row = mysqli_fetch_assoc($result)) {
        echo "<tr>";
        echo "<td>{$row['doc_no']}</td>";
        echo "<td>{$row['dname']}</td>";
        echo "<td>{$row['address']}</td>";
        echo "<td>{$row['city']}</td>";
        echo "<td>{$row['area']}</td>";
        echo "</tr>";
    }

    echo "</table>";
    mysqli_free_result($result);
}
?>

<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
    Enter Hospital Name: <input type="text" name="hospitalName">
    <input type="submit" value="Show Doctors Visiting">
</form>
</body> </html>

Q2]
A]
import numpy as np
import matplotlib.pyplot as plt

Generate a random array of 50 integers

np.random.seed(42)
data = np.random.randint(1, 100, 50)

Display using line chart, scatter plot, histogram, and box plot

fig, axes = plt.subplots(2, 2, figsize=(12, 8))

Line chart

axes[0, 0].plot(data, color='green')
axes[0, 0].set_title('Line Chart')

Scatter plot

axes[0, 1].scatter(range(1, 51), data, color='red')
axes[0, 1].set_title('Scatter Plot')

Histogram

axes[1, 0].hist(data, bins=10, color='blue', alpha=0.7)
axes[1, 0].set_title('Histogram')

Box plot

axes[1, 1].boxplot(data, vert=False)
axes[1, 1].set_title('Box Plot')

plt.tight_layout()
plt.show()

B]
import matplotlib.pyplot as plt

Create two lists representing subject names and marks obtained

subjects = ['Math', 'English', 'Science', 'History', 'Art']
marks = [90, 85, 92, 88, 78]

Display data in a bar chart

plt.bar(subjects, marks, color=['skyblue', 'lightcoral', 'lightgreen', 'lightpink', 'lightyellow'])
plt.xlabel('Subjects')
plt.ylabel('Marks')
plt.title('Subject-wise Marks')
plt.show()