Assignment Objectives: Dr. Anil Saroliya
Assignment Objectives: Dr. Anil Saroliya
Anil Saroliya:____________
Lab-1
Assignment: Create your personal profile site using HTML, CSS, etc.
Objectives: Learn basics of HTML&CSS and make simple website.
Solution:
HTML code:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Document</title>
</head>
<body>
<h1> <center>Это мой профиль</center> </h1>
<nav>
<a href="#">Home</a>
<a href="#">About me</a>
<a href="#">Qualification</a>
<a href="#">Contacts</a>
</nav>
<div class="con">
<h2><center>Experience</center></h2>
<div class="sub_con">
<p> Lorem ipsum dolor sit amet, consectetur
adipisicing elit. Dolorem vero id officiis consequuntur
eos deserunt officia magni accusamus voluptatibus est at
accusantium fugiat assumenda dolor quod tempora quas, fugit
facilis dolores incidunt vitae nulla voluptate quidem laudantium.
Quam rem unde cum ipsam, nihil saepe repellat porro velit id
molestias maiores deleniti perspiciatis impedit illum minima ex.
Pariatur alias dicta ratione sapiente quos ipsa ex consequuntur
sit vel. Quidem voluptates aperiam reiciendis sunt. Officiis,
fuga, ipsa enim esse inventore nam nisi voluptate impedit
laudantium blanditiis minus nesciunt ab odit architecto
voluptatibus obcaecati amet velit illo magnam expedita
ratione. Aperiam, hic dolores. </p>
<img src="eqwe.jpg" alt="wal">
</div>
<div class="pics">
<img class="img" src="wal.jpg" alt="wal">
<img class="img"src="wal.jpg" alt="wal">
<img class="img"src="wal.jpg" alt="wal">
</div>
</div>
</body>
</html>
CSS code:
body{
width: 50%;
}
nav{
align-items: center;
background-color: grey;
padding: 10px;
display: flex;
justify-content: space-around;
}
a{
text-decoration: none;
}
img{
width: 250px;
}
.img{
width: 250px;
}
.sub_con{
display: flex;
justify-content: space-between;
}
.pics{
margin-top: 20px;
display: flex;
justify-content: space-between;
}
p{
width: 400px;
}
Dr. Anil Saroliya:____________
Lab-2
Assignment: Do the exercises mentioned below.
Objectives: Get closer to syntax of the language and write simple codes.
Code: Output:
<?php
$val = 8;
echo "Value is now $val <br>";
$val += 2;
echo "Value is now $val <br>";
$val -= 4;
echo "Value is now $val <br>";
$val *= 10;
echo "Value is now $val <br>";
$val /=3;
echo "Value is now $val <br>";
$val++;
echo "Value is now $val <br>";
$val--;
echo "Value is now $val <br>";
?>
2. For this PHP exercise, write a script using the following variable:
$around="around";
•Single quotes and double quotes don't work the same way in PHP. Using single quotes (' ') and the
concatenation operator, echo the following to the browser, using the variable you created:
What goes around, comes around.
Code:
$around="around";
echo 'What goes '.$around. ', comes ' .$around;
Output:
What goes around, comes around
3. In this PHP exercise, you will use a conditional statement to determine what gets printed to the
browser. Write a script that gets the current month and prints one of the following responses, depending
on whether it's August or not:
It’s September, so it’s somehow hot.
Not September, so at least not in the peak of the heat.
•Hint: the function to get the current month is 'date('F', time())' for the
month's full name.
Code:
$month = date("m");
if ($month == 9) {
echo "<br>It’s September, so it’s somehow hot <br>";
}
else {
echo "Not September, so at least not in the peak of the heat.";
}
Output:
Not September, so at least not in the peak of the heat.
4. Loops are very useful in creating lists and tables. In this PHP exercise, you will use a loop to create a
list of equations for squares.•Using a for loop, write a script that will send to the browser a list of
squares for the numbers 1-12.
Use the format, "1 * 1 = 1", and be sure to include code to print each
formula on a different line
Code:
<?php
$x = 1;
$y = 12;
for($x; $x <= $y; $x++) {
for($z=1; $z <= $y; $z++){
echo "<br>$x * $z = " . $x * $z . "<br>";
}
}
Output:
5. HTML tables involve a lot of repetitive coding - a perfect place to use for loops.
You can do even more if you nest the for loops.
• In this PHP exercise, use two for loops, one nested inside another. Create the
following multiplication table:
Code:
<style>
table {
border-collapse: collapse;
width: 100%;
}
td {
background-color: yellow;
border: 1px solid black;
}
</style>
<?php
$rows = [];
$x= 1;
$y= 7;
<table>
<?php foreach ($rows as $row): ?>
<tr>
<?php foreach ($row as $column): ?>
<td><?= $column ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>
Output:
Lab-5
Lab Assignment-5
Write a PHP program using nested for loop that creates a chess board.
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<table width="270px" cellspacing="0px" cellpadding="0px" border="1px">
<!-- cell 270px wide (8 columns x 60px) -->
<?php
for($row=1;$row<=8;$row++)
{
echo "<tr>";
for($col=1;$col<=8;$col++)
{
$total=$row+$col;
if($total%2==0)
{
echo "<td height=30px width=30px bgcolor=#FFFFFF></td>";
}
else
{
echo "<td height=30px width=30px bgcolor=#000000></td>";
}
}
echo "</tr>";
}
?>
</table>
</body>
</html>
Output:
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<?php
$result_str = $result = '';
if (isset($_POST['unit-submit'])) {
$units = $_POST['units'];
if (!empty($units)) {
$result = calculate($units);
$result_str = 'Total amount of ' . $units . ' - ' . $result;
}
}
function calculate($units) {
$first = 3.50;
$second = 4.00;
$third = 5.20;
$fourth = 6.50;
?>
<body>
<h1>Php - Calculate Electricity Bill</h1>
Output: