OneCompiler

Hslip29

137

Q1]

<!DOCTYPE html> <html> <head> <title>Modify Committee Status</title> </head> <body> <?php // Assuming you have established a connection to the database
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $eventTitle = $_POST["eventTitle"];

    // Fetch the eno for the given event title
    $queryEvent = "SELECT eno FROM Event WHERE title = '$eventTitle'";
    $resultEvent = mysqli_query($connection, $queryEvent);

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

    $rowEvent = mysqli_fetch_assoc($resultEvent);
    $eno = $rowEvent['eno'];
    mysqli_free_result($resultEvent);

    // Update the status of the committee to 'working' for the specified event
    $queryUpdate = "UPDATE Committee SET status = 'working' WHERE cno IN 
                    (SELECT cno FROM Event_Committee WHERE eno = '$eno')";

    $resultUpdate = mysqli_query($connection, $queryUpdate);

    if (!$resultUpdate) {
        die("Update failed: " . mysqli_error($connection));
    }

    echo "Status of Committees for the event '$eventTitle' has been modified to 'working'.";
}
?>

<h2>Modify Committee Status</h2>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
    Enter Event Title: <input type="text" name="eventTitle">
    <input type="submit" value="Modify Committee Status">
</form>
</body> </html>

Q2]
import pandas as pd
from sklearn.preprocessing import OneHotEncoder, LabelEncoder

Create a dataset data.csv

data = {'Country': ['USA', 'India', 'UK', 'Canada', 'India', 'USA'],
'Purchased': ['Yes', 'No', 'Yes', 'No', 'Yes', 'No']}
df = pd.DataFrame(data)

1. Apply OneHot coding on Country column

onehot_encoder = OneHotEncoder(sparse=False)
onehot_encoded = onehot_encoder.fit_transform(df[['Country']])
onehot_df = pd.DataFrame(onehot_encoded, columns=['Country_' + country for country in onehot_encoder.get_feature_names_out(['Country'])])
df = pd.concat([df, onehot_df], axis=1)
df.drop(columns=['Country'], inplace=True)

2. Apply Label encoding on Purchased column

label_encoder = LabelEncoder()
df['Purchased'] = label_encoder.fit_transform(df['Purchased'])

Display the modified dataset

print("Modified Dataset:")
print(df)