Lab Activity[5a]
Lab Activity[5a]
Signature
1. Create Folder lab5a_q1.php
<!DOCTYPE html>
<html lang="en">
<head>
<title>Lab 5a Q1</title>
</head>
<body>
<?php
$name = "Solehudin YUsuf";
$matricNumber = "JI240008";
$course = "Web Development";
$yearOfStudy = "2024";
$address = "Johor";
?>
<table>
<tr>
<td>Name</td>
<td><?php echo "$name"; ?></td>
</tr>
<tr>
<td>MatricNumber</td>
<td><?php echo "$matricNumber"; ?></td>
</tr>
<tr>
<td>Course</td>
<td><?php echo "$course"; ?></td>
</tr>
<tr>
<td>Year of Study</td>
<td><?php echo "$yearOfStudy"; ?></td>
</tr>
<tr>
<td>Address</td>
<td><?php echo "$address"; ?></td>
</tr>
</table>
</body>
</html>
2. Create php file lab5a_q2.php
<?php
$students = [
[
'name' => 'Alice',
'program' => 'BIP',
'age' => 21,
],
[
'name' => 'Bob',
'program' => 'BIS',
'age' => 20,
],
[
'name' => 'Raju',
'program' => 'BIT',
'age' => 22,
],
];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Student Table</title>
<style>
table {
border-collapse: collapse;
width: 50%;
margin: 20px auto;
}
th, td {
border: 1px solid black;
padding: 8px;
text-align: center;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<table>
<thead>
<tr>
<th>Name</th>
<th>Program</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<?php foreach ($students as $student): ?>
<tr>
<td><?php echo $student['name']; ?></td>
<td><?php echo $student['program']; ?></td>
<td><?php echo $student['age']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>
3. Create php file lab5a_q3.php
<?php
// Function to generate multiplication table
function multiplication($multiplier) {
$results = [];
for ($i = 1; $i <= 12; $i++) {
$results[] = [
'No' => $i,
'Multiplier' => $multiplier,
'Answer' => $i * $multiplier,
];
}
return $results;
}
4. https://github.com/ucuypa/lab_5a