0% found this document useful (0 votes)
3 views7 pages

Lab Activity (5a)

Uploaded by

Solehudin Yusuf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views7 pages

Lab Activity (5a)

Uploaded by

Solehudin Yusuf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Course Code BIC21203

Course Name WEB DEVELOPMENT

Title Web page development using PHP


Name Solehudin Yusuf
Matric Number JI240008
Lab Activity number Lab Activity #5a
Submission Date 8 December 2024

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;
}

// Call the function with a given multiplier (e.g., 5)


$multiplier = 5; // You can change this number
$multiplicationTable = multiplication($multiplier);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Multiplication Table</title>
<style>
table {
width: 50%;
border-collapse: collapse;
margin: 20px auto;
}
th, td {
border: 1px solid black;
padding: 8px;
text-align: center;
}
th {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<h2 style="text-align: center;">Multiplication Table for <?php echo
$multiplier; ?></h2>
<table>
<thead>
<tr>
<th>No</th>
<th>Multiplier</th>
<th>Answer</th>
</tr>
</thead>
<tbody>
<?php foreach ($multiplicationTable as $row): ?>
<tr>
<td><?php echo $row['No']; ?></td>
<td><?php echo $row['Multiplier']; ?></td>
<td><?php echo $row['Answer']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</body>
</html>

4. https://github.com/ucuypa/lab_5a

You might also like