VISVESVARAYA TECHNOLOGICAL UNIVERSITY
Jnana Sangama, Belagavi - 590014
PRACTICAL ASSESSMENT REPORT
ON
WEB TECHNOLOGY & ITS APPLICATION
18CS63
Submitted in partial fulfilment of the requirements for the VI Semester
Bachelor of Engineering
In
INFORMATION SCIENCE AND ENGINEERING
SUBMITTED BY
AISHWARYA A
(1VK19IS001)
JANATHA EDUCATION SOCIETY
VIVEKANANDA INSTITUTE OF TECHNOLOGY
DEPARTMENT OF INFORMATION SCIENCE AND ENGINEERING
Kumbalagodu, Bengaluru-560074
2021-2022
CONTENTS
Sl TOPIC PAGE
No. No.
1 Syllabus 1-2
2 Software requirements specification 3-5
3 Program 1 - JavaScript : Simple calculator. 6-8
4 Program 2 - JavaScript : Calculate squares and cubes of the numbers 9-10
from 7 0 to 10.
5 Program 3 - JavaScript : TEXT-GROWING and TEXT-SHRINKING 11-12
6 Program 4 - HTML5 and JavaScript : 13-14
a) position in the string of the left-most vowel.
b) number with its digits in the reverse order.
7 Program 5 - XML document to store information about a student. 15-18
8 Program 6 - PHP : display the number of visitors visiting the web page. 19-20
9 Program 7 - PHP : display digital clock with current time of the server. 21-22
10 Program 8 - PHP : 23-28
a) Implement simple calculator operations.
b) Find the Transpose of a matrix, Multiplication of two matrices
and Addition of two matrices.
11 Program 9 – PHP : program with variable states with value. 29-31
“Mississippi Alabama Texas Massachusetts Kansas"
12 Program 10 – PHP : program to sort the student records using selection 32-35
sort.
Practical Assessment-Web Technology-18CS63
WEB TECHNOLOGY LABORATORY WITH MINI PROJECT
[As per Choice Based Credit System (CBCS) scheme]
(Effective from the academic year 2021 -2022)
SEMESTER – VI
1. Write a JavaScript to design a simple calculator to perform the following operations:
sum, product, difference and quotient.
2. Write a JavaScript that calculates the squares and cubes of the numbers from 0 to 10and
outputs HTML text that displays the resulting values in an HTML table format.
3. Write a JavaScript code that displays text “TEXT-GROWING” with increasing font size
in the interval of 100ms in RED COLOR, when the font size reaches 50pt it displays
“TEXT-SHRINKING” in BLUE colour. Then the font size decreases to 5pt.
4. Develop and demonstrate a HTML5 file that includes JavaScript script that uses
functions for the following problems:
a) Parameter: A string
b) Output: The position in the string of the left-most vowel
c) Parameter: A number
d) Output: The number with its digits in the reverse order
5. Design an XML document to store information about a student in an engineering college
affiliated to VTU. The information must include USN, Name, and Name of the College,
Branch, Year of Joining, and email id. Make up sample data for 3students. Create a CSS
style sheet and use it to display the document.
6. Write a PHP program to keep track of the number of visitors visiting the web page and
to display this count of visitors, with proper headings.
7. Write a PHP program to display a digital clock which displays the current time of the
server.
8. Write the PHP programs to do the following:
a) Implement simple calculator operations.
b) Find the transpose of a matrix.
c) Multiplication of two matrices.
[Link] ISE,VKIT 2021-22 PAGE 1
Practical Assessment-Web Technology-18CS63
d) Addition of two matrices.
9. Write a PHP program named [Link] that declares a variable states with value
“Mississippi Alabama Texas Massachusetts Kansas". write a PHP program that does the
following:
a) Search for a word in variable states that ends in xas. Store this word in element0 of
a list named states List.
b) Search for a word in states that begins with k and ends in s. Perform a case-insensitive
comparison. [Note: Passing [Link] a second parameter to method compile performs a
case-insensitive comparison.] Store this word in element1of states List.
c) Search for a word in states that begins with M and ends in s. Store this word in
element 2 of the list
d) Search for a word in states that ends in a. Store this word in element 3 of the list.
10. Write a PHP program to sort the student records which are stored in the database using
selection sort.
[Link] ISE,VKIT 2021-22 PAGE 2
Practical Assessment-Web Technology-18CS63
Software Requirement Specification
The Software Requirements Specification is produced at the culmination of the analysis task.
The function and performance allocated to software as part of system engineering are refined
by establishing a complete information description, a detailed functional and behavioural
description, an indication of performance.
Software Interfaces
1. Visual Studio 2021
2. OS: Windows Vista/7/8/10/11
3. DB Server: Xampp
4. Front End Language: HTML, CSS, JS, PHP, MYSQL
Hardware interfaces
1. Intel core i3 processor with minimum 2GHZ speed.
2. RAM: Minimum 4GB
3. Hard Disk: Minimum 1TB
About technologies Used
MYSQL
MYSQL is language used to manipulate relational databases. It is tied closely with relational
model. It is issued for the purpose of data definition and data manipulation. Program runs as
server providing multi-user access to number of databases. MySQL is a multithreaded, multi-
user SQL database management system (DBMS). It includes facilities to add, modify or delete
data from the database, ask questions (or queries) about the data stored in database and produce
reports summarizing selected contents.
[Link] ISE,VKIT 2021-22 PAGE 3
Practical Assessment-Web Technology-18CS63
PHP
Hypertext Preprocessor (or simply PHP) is a server-side scripting language designed for Web
development, but also used as a general-purpose programming language. It was originally
created by Rasmus Lerdorf in 1994,] the PHP reference implementation is now produced by
The PHP Group. PHP originally stood for Personal Home Page, ] but it now stands for the
Recursive acronym PHP: Hypertext Preprocessor PHP code may be embedded into HTML
code, or it can be used in combination with various web template systems, web content
management systems, and web frameworks. PHP code is usually processed by a PHP interpreter
implemented as a module in the web server or as a Common Gateway Interface (CGI)
executable. The web server combines the results of the interpreted and executed PHP code,
which may be any type of data, including images, with the generated web page. PHP code may
also be executed with a command-line interface (CLI) and can be used to implement standalone
graphical applications.
Xampp
XAMPP is a free and open source cross-platform web server solution stack package developed by
Apache Friends, consisting mainly of the Apache HTTP Server, MariaDB database, and
interpreters for scripts written in the PHP and programming languages. XAMPP stands for Cross-
Platform (X), Apache (A), MariaDB (M), PHP (P) and Perl (P). It is a simple, lightweight Apache
distribution that makes it extremely easy for developers to create a local web server for testing and
deployment purposes. Everything needed to set up a web server – server application (Apache),
database (MariaDB), and scripting language (PHP) – is included in an extractable file. XAMPP is
also cross-platform, which means it works equally well on.
HTML
Hypertext Markup Language (HTML) is the standard markup language for creating web pages
and web applications. With Cascading Style Sheets (CSS) and JavaScript, it forms a triad of
cornerstone technologies for the Web browsers receive HTML documents from a server or from
[Link] ISE,VKIT 2021-22 PAGE 4
Practical Assessment-Web Technology-18CS63
local storage and render the documents into multimedia web pages. HTML describes the structure
of a web page semantically and originally included cues for the appearance of the
[Link] elements are the building blocks of HTML pages. With HTML constructs,
images and other objects such as interactive forms may be embedded into the rendered page.
CSS
Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a
document written in a markup language such as HTML or XML (including XML dialects such as
SVG, MathML or XHTML). CSS is a cornerstone technology of the World Wide Web, alongside
HTML and JavaScript. CSS is designed to enable the separation of presentation and content,
including layout, colors, and fonts. This separation can improve content accessibility; provide
more flexibility and control in the specification of presentation characteristics; enable
multiple web pages to share formatting by specifying the relevant CSS in a separate .css file, which
reduces complexity and repetition in the structural content; and enable the .css file to be cached to
improve the page load speed between the pages that share the file and its formatting.
JAVASCRIPT
JavaScript often abbreviated JS, is a programming language that is one of the core technologies
of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of websites use JavaScript
on the client side for web page behavior, often incorporating third-party libraries. All major web
browsers have a dedicated JavaScript engine to execute the code on users' devices. JavaScript is
a high-level, often just-in-time compiled language that conforms to the ECMAScript standard. It
has dynamic typing, prototype-based object-orientation, and first-class functions. It is multi-
paradigm, supporting event-driven, functional, and imperative programming styles. It
has application programming interfaces (APIs) for working with text, dates, regular expressions,
standard data structures, and the Document Object Model (DOM).The ECMAScript standard
does not include any input/output (I/O), such as networking, storage, or graphics facilities. In
practice, the web browser or other runtime system provides JavaScript APIs for I/O.
[Link] ISE,VKIT 2021-22 PAGE 5
Practical Assessment-Web Technology-18CS63
PROGRAM 1 :
Write a JavaScript to design a simple calculator to perform the following operations: sum,
product, difference and quotient.
[Link]
<!DOCTYPE HTML>
<html>
<head>
<style>
table, td, th
{
border: 1px solid black;
width: 33%;
text-align: center;
background-color: DarkGray;
border-collapse:collapse;
}
table { margin: auto; }
input { text-align:right; }
</style>
<script type="text/javascript">
function calc(clicked_id)
{
var val1 = parseFloat([Link]("value1").value);
var val2 = parseFloat([Link]("value2").value);
if(isNaN(val1)||isNaN(val2))
alert("ENTER VALID NUMBER");
else if(clicked_id=="add")
[Link]("answer").value=val1+val2;
else if(clicked_id=="sub")
[Link]("answer").value=val1-val2;
else if(clicked_id=="mul")
[Link]("answer").value=val1*val2;
else if(clicked_id=="div")
[Link]("answer").value=val1/val2;
}
function cls()
{
[Link]="0";
[Link]="0";
[Link]="";
}
[Link] ISE,VKIT 2021-22 PAGE 6
Practical Assessment-Web Technology-18CS63
</script>
</head>
<body>
<table>
<tr><th colspan="4"> SIMPLE CALCULATOR </th></tr>
<tr><td>value1</td><td><input type="text" id="value1" value="0"/></td>
<td>value2</td><td><input type="text" id="value2" value="0"/> </td></tr>
<tr><td><input type="button" value="Addition" id = "add"
onclick="calc([Link])"/></td>
<td><input type="button" value="Subtraction" id = "sub"
onclick="calc([Link])"/></td>
<td><input type="button" value="Multiplication" id = "mul"
onclick="calc([Link])"/></td>
<td><input type="button" value="Division" id ="div"
onclick="calc([Link])"/></td></tr>
<tr><td>Answer:</td><td> <input type="text" id="answer" value=""
disabled/></td>
<td colspan="2"><input type="button" value="CLEAR ALL" onclick="cls()"/></td>
</tr>
</table>
</body>
</html>
[Link] ISE,VKIT 2021-22 PAGE 7
Practical Assessment-Web Technology-18CS63
OUTPUT
[Link] ISE,VKIT 2021-22 PAGE 8
Practical Assessment-Web Technology-18CS63
PROGRAM 2 :
Write a JavaScript that calculates the squares and cubes of the numbers from 0 to 10and
outputs HTML text that displays the resulting values in an HTML table format.
[Link]
<!DOCTYPE HTML>
<html>
<head>
<style>
table,tr,td
{
border: solid black;
width: 33%;
text-align: center;
border-collapse: collapse;
background-color:lightblue;
}
table { margin: auto; }
</style>
<script>
[Link]( "<table><tr><th colspan='3'> NUMBERS FROM 0 TO 10 WITH
THEIR SQUARES AND CUBES </th></tr>" );
[Link]( "<tr><td>Number</td><td>Square</td><td>Cube</td></tr>" );
for(var n=0; n<=10; n++)
{
[Link]( "<tr><td>" + n + "</td><td>" + n*n + "</td><td>" + n*n*n+
"</td></tr>" ) ;
}
[Link]( "</table>" ) ;
</script>
</head>
</html>
[Link] ISE,VKIT 2021-22 PAGE 9
Practical Assessment-Web Technology-18CS63
OUTPUT
[Link] ISE,VKIT 2021-22 PAGE 1 0
Practical Assessment-Web Technology-18CS63
PROGRAM 3 :
Write a JavaScript code that displays text “TEXT-GROWING” with increasing font size in
the interval of 100ms in RED COLOR, when the font size reaches 50pt it displays “TEXT-
SHRINKING” in BLUE colour. Then the font size decreases to 5pt.
[Link]
<!DOCTYPE HTML>
<html>
<head>
<style>
p{
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>
</head>
<body>
<p id="demo"></p>
<script>
var var1 = setInterval(inTimer, 1000);
var fs = 5;
var ids = [Link]("demo");
function inTimer() {
[Link] = 'TEXT GROWING';
[Link]('style', "font-size: " + fs + "px; color: red");
fs += 5;
if(fs >= 50 ){
clearInterval(var1);
var2 = setInterval(deTimer, 1000);
}
}
function deTimer() {
fs -= 5;
[Link] = 'TEXT SHRINKING';
[Link]('style', "font-size: " + fs + "px; color: blue");
if(fs === 5 ){
clearInterval(var2);
}
}
[Link] ISE,VKIT 2021-22 PAGE 1 1
Practical Assessment-Web Technology-18CS63
</script>
</body>
</html>
OUTPUT
[Link] ISE,VKIT 2021-22 PAGE 1 2
Practical Assessment-Web Technology-18CS63
PROGRAM 4 :
Develop and demonstrate a HTML5 file that includes JavaScript script that uses functions for
the following problems:
a) Parameter: A string
b) Output: The position in the string of the left-most vowel
c) Parameter: A number
d) Output: The number with its digits in the reverse order.
[Link]
<!DOCTYPE HTML>
<html>
<body>
<script type="text/javascript">
var str = prompt("Enter the Input","");
if(!(isNaN(str)))
{
var num,rev=0,remainder;
num = parseInt(str);
while(num!=0) {
remainder = num%10;
num = parseInt(num/10);
rev = rev * 10 + remainder;
}
alert("Reverse of "+str+" is "+rev);
}
else
{
str = [Link]();
for(var i = 0; i < [Link]; i++) {
var chr = [Link](i);
if(chr == 'A' || chr == 'E' || chr == 'I' || chr == 'O' || chr == 'U')break;
}
if( i < [Link] )
alert("The position of the left most vowel is "+(i+1));
else
alert("No vowel found in the entered string");
}
</script>
</body> </html>
[Link] ISE,VKIT 2021-22 PAGE 1 3
Practical Assessment-Web Technology-18CS63
OUTPUT
[Link] ISE,VKIT 2021-22 PAGE 1 4
Practical Assessment-Web Technology-18CS63
PROGRAM 5 :
Design an XML document to store information about a student in an engineering college
affiliated to VTU. The information must include USN, Name, and Name of the College,
Branch, Year of Joining, and email id. Make up sample data for 3students. Create a CSS style
sheet and use it to display the document.
[Link]
<?xml-stylesheet type="text/css" href="[Link]" ?>
<!DOCTYPE HTML>
<html>
<head>
<h1> STUDENTS DESCRIPTION </h1>
</head>
<students>
<student>
<USN>USN : 1VK19IS001</USN>
<name>NAME : Aishwarya A</name>
<college>COLLEGE : VKIT</college>
<branch>BRANCH : Information Science and Engineering</branch>
<year>YEAR : 2019</year>
<e-mail>E-Mail : Aish1108@[Link]</e-mail>
</student>
<student>
<USN>USN : 1VK19IS021</USN>
<name>NAME : Yashas S</name>
[Link] ISE,VKIT 2021-22 PAGE 1 5
Practical Assessment-Web Technology-18CS63
<college>COLLEGE : VKIT</college>
<branch>BRANCH : Information Science and Engineering </branch>
<year>YEAR : 2019</year>
<e-mail>E-Mail : Yashas682@[Link]</e-mail>
</student>
<student>
<USN>USN : 1VK19IS012</USN>
<name>NAME : Nividea</name>
<college>COLLEGE : VKIT</college>
<branch>BRANCH : Information Science and Engineering
</branch>
<year>YEAR : 2019</year>
<e-mail>E-Mail : [Link]</e-mail>
</student>
</students>
</html>
[Link]
student{
display:block; margin-top:10px; color:Navy;
USN{
display:block; margin-left:10px;font-size:14pt; color:Red;
[Link] ISE,VKIT 2021-22 PAGE 1 6
Practical Assessment-Web Technology-18CS63
name{
display:block; margin-left:20px;font-size:14pt; color:Blue;
college{
display:block; margin-left:20px;font-size:12pt; color:Maroon;
branch{
display:block; margin-left:20px;font-size:12pt; color:Purple;
year{
display:block; margin-left:20px;font-size:14pt; color:Green;
e-mail{
display:block; margin-left:20px;font-size:12pt; color:Blue;
[Link] ISE,VKIT 2021-22 PAGE 1 7
Practical Assessment-Web Technology-18CS63
OUTPUT
[Link] ISE,VKIT 2021-22 PAGE 1 8
Practical Assessment-Web Technology-18CS63
PROGRAM 6 :
Write a PHP program to keep track of the number of visitors visiting the web page and to
display this count of visitors, with proper headings.
[Link]
<?php
print "<h3> REFRESH PAGE </h3>";
$name="[Link]";
$file = fopen($name,"r");
$hits= fscanf($file,"%d");
fclose($file);
$hits[0]++;
$file = fopen($name,"w");
fprintf($file,"%d",$hits[0]);
fclose($file);
print "Total number of views: ".$hits[0];
?>
[Link] ISE,VKIT 2021-22 PAGE 1 9
Practical Assessment-Web Technology-18CS63
OUTPUT
[Link] ISE,VKIT 2021-22 PAGE 2 0
Practical Assessment-Web Technology-18CS63
PROGRAM 7 :
Write a PHP program to display a digital clock which displays the current time of the server.
[Link]
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="refresh" content="1"/>
<style>
p{
color:white;
font-size:90px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
body{background-color:black;}
</style>
<p> <?php echo date(" h: i : s A");?> </p>
</head>
[Link] ISE,VKIT 2021-22 PAGE 2 1
Practical Assessment-Web Technology-18CS63
OUTPUT
[Link] ISE,VKIT 2021-22 PAGE 2 2
Practical Assessment-Web Technology-18CS63
PROGRAM 8 :
Write the PHP programs to do the following:
a) Implement simple calculator operations.
b) Find the transpose of a matrix.
c) Multiplication of two matrices.
d) Addition of two matrices.
[Link]
<html>
<head>
<style>
table, td, th
border: 1px solid black;
width: 35%;
text-align: center;
background-color: DarkGray;
table { margin: auto; }
input,p { text-align:right; }
</style>
</head>
<body>
<form method="post">
<table>
[Link] ISE,VKIT 2021-22 PAGE 2 3
Practical Assessment-Web Technology-18CS63
<caption><h2> SIMPLE CALCULATOR </h2></caption>>
<tr><td>First Number:</td><td><input type="text" name="num1" /></td>
<td rowspan="2"><input type="submit" name="submit"
value="calculate"></td></tr>
<tr><td>Second Number:</td><td><input type ="text"
name="num2"/></td></tr>
</form>
<?php
if(isset($_POST['submit'])) // it checks if the input submit is filled
$num1 = $_POST['num1'];
$num2 = $_POST['num2'];
if(is_numeric($num1) and is_numeric($num1) )
echo "<tr><td> Addition :</td><td><p>".($num1+$num2)."</p></td>";
echo "<tr><td> Subtraction :</td><td><p> ".($num1-$num2)."</p></td>";
echo "<tr><td> Multiplication :</td><td><p>".($num1*$num2)."</p></td>";
echo "<tr><td>Division :</td><td><p> ".($num1/$num2)."</p></td>";
echo "</table>";
else
echo"<script type='text/javascript' > alert(' ENTER VALID
[Link] ISE,VKIT 2021-22 PAGE 2 4
Practical Assessment-Web Technology-18CS63
NUMBER');</script>";
?>
</body>
</html>
OUTPUT
[Link] ISE,VKIT 2021-22 PAGE 2 5
Practical Assessment-Web Technology-18CS63
Program [Link]
<?php
[Link]
$a = array(array(1,2,3),array(4,5,6),array(7,8,9));
$b = array(array(7,8,9),array(4,5,6),array(1,2,3));
$m=count($a);
$n=count($a[2]);
$p=count($b);
$q=count($b[2]);
echo "the first matrix :"."<br/>";
for ($row = 0; $row < $m; $row++) {
for ($col = 0; $col < $n; $col++)
echo " ".$a[$row][$col];
echo "<br/>";
echo "the second matrix :"."<br/>";
for ($row = 0; $row < $p; $row++) {
for ($col = 0; $col < $q; $col++)
echo " ".$b[$row][$col];
echo "<br/>";
echo "the transpose for the first matrix is:"."<br/>";
for ($row = 0; $row < $m; $row++) {
[Link] ISE,VKIT 2021-22 PAGE 2 6
Practical Assessment-Web Technology-18CS63
for ($col = 0; $col < $n; $col++)
echo " ".$a[$col][$row];
echo "<br/>";
if(($m===$p) and ($n===$q)) {
echo "the addition of matrices is:"."<br/>";
for ($row = 0; $row < 3; $row++) {
for ($col = 0; $col < 3; $col++)
echo " ".$a[$row][$col]+$b[$row][$col]." ";
echo "<br/>";
if($n===$p){
echo " The multiplication of matrices: <br/>";
$result=array();
for ($i=0; $i < $m; $i++) {
for($j=0; $j < $q; $j++){
$result[$i][$j] = 0;
for($k=0; $k < $n; $k++)
$result[$i][$j] += $a[$i][$k] * $b[$k][$j];
for ($row = 0; $row < $m; $row++) {
[Link] ISE,VKIT 2021-22 PAGE 2 7
Practical Assessment-Web Technology-18CS63
for ($col = 0; $col < $q; $col++)
echo " ".$result[$row][$col];
echo "<br/>";
?>
OUTPUT
[Link] ISE,VKIT 2021-22 PAGE 2 8
Practical Assessment-Web Technology-18CS63
PROGRAM 9 :
Write a PHP program named [Link] that declares a variable states with value “Mississippi
Alabama Texas Massachusetts Kansas". write a PHP program that does the following:
a) Search for a word in variable states that ends in xas. Store this word in element0 of a
list named states List.
b) Search for a word in states that begins with k and ends in s. Perform a case-insensitive
comparison. [Note: Passing [Link] a second parameter to method compile performs a
case-insensitive comparison.] Store this word in element1of states List.
c) Search for a word in states that begins with M and ends in s. Store this word in element
2 of the list.
d) Search for a word in states that ends in a. Store this word in element 3 of the list.
[Link]
<?php
$states = "Mississippi Alabama Texas Massachusetts Kansas";
$statesArray = [];
$states1 = explode(' ',$states);
echo "Original Array :<br>";
foreach ( $states1 as $i => $value )
print("STATES[$i]=$value<br>");
foreach($states1 as $state) {
if(preg_match( '/xas$/', ($state)))
$statesArray[0] = ($state);
foreach($states1 as $state) {
if(preg_match('/^k.*s$/i', ($state)))
[Link] ISE,VKIT 2021-22 PAGE 2 9
Practical Assessment-Web Technology-18CS63
$statesArray[1] = ($state);
foreach($states1 as $state) {
if(preg_match('/^M.*s$/', ($state)))
$statesArray[2] = ($state);
foreach($states1 as $state){
if(preg_match('/a$/', ($state)))
$statesArray[3] = ($state);
echo "<br><br>Resultant Array :<br>";
foreach ( $statesArray as $array => $value )
print("STATES[$array]=$value<br>");
?>
[Link] ISE,VKIT 2021-22 PAGE 3 0
Practical Assessment-Web Technology-18CS63
OUTPUT
[Link] ISE,VKIT 2021-22 PAGE 3 1
Practical Assessment-Web Technology-18CS63
PROGRAM 10 :
Write a PHP program to sort the student records which are stored in the database using
selection sort.
[Link]
<!DOCTYPE html>
<html>
<body>
<style>
table, td, th
{
border: 1px solid black;
width: 33%;
text-align: center;
border-collapse:collapse;
background-color:lightblue;
}
table { margin: auto; }
</style>
<?php
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "weblab";
$a=[];
// Create connection
// Opens a new connection to the MySQL server
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection and return an error description from the last
connection error, if any
[Link] ISE,VKIT 2021-22 PAGE 3 2
Practical Assessment-Web Technology-18CS63
if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);
$sql = "SELECT * FROM student";
// performs a query against the database
$result = $conn->query($sql);
echo "<br>";
echo "<center> BEFORE SORTING </center>";
echo "<table border='2'>";
echo "<tr>";
echo "<th>USN</th><th>NAME</th><th>Address</th></tr>";
if ($result->num_rows> 0)
{
// output data of each row and fetches a result row as an
associative array
while($row = $result->fetch_assoc()){
echo "<tr>";
echo "<td>". $row["usn"]."</td>";
echo "<td>". $row["name"]."</td>";
echo "<td>". $row["addr"]."</td></tr>";
array_push($a,$row["usn"]);
}
else
}
echo "Table is Empty";
echo "</table>";
$n=count($a);
$b=$a;
for ( $i = 0 ; $i< ($n - 1) ; $i++ )
{
$pos= $i;
[Link] ISE,VKIT 2021-22 PAGE 3 3
Practical Assessment-Web Technology-18CS63
for ( $j = $i + 1 ; $j < $n ; $j++ ) {
if ( $a[$pos] > $a[$j] )
$pos= $j;
}
if ( $pos!= $i ) {
$temp=$a[$i];
$a[$i] = $a[$pos];
$a[$pos] = $temp;
}
}
$c=[];
$d=[];
$result = $conn->query($sql);
if ($result->num_rows> 0)// output data of each row
{
while($row = $result->fetch_assoc()) {
for($i=0;$i<$n;$i++) {
if($row["usn"]== $a[$i]) {
$c[$i]=$row["name"];
$d[$i]=$row["addr"];
}
}
}
}
echo "<br>";
echo "<center> AFTER SORTING <center>";
echo "<table border='2'>";
echo "<tr>";
echo "<th>USN</th><th>NAME</th><th>Address</th></tr>";
for($i=0;$i<$n;$i++) {
[Link] ISE,VKIT 2021-22 PAGE 3 4
Practical Assessment-Web Technology-18CS63
echo "<tr>";
echo "<td>". $a[$i]."</td>";
echo "<td>". $c[$i]."</td>";
echo "<td>". $d[$i]."</td></tr>";
}
echo "</table>";
$conn->close();
?>
</body>
</html>
OUTPUT
[Link] ISE,VKIT 2021-22 PAGE 3 5
BIBLIOGRAPHY
1. Randy Connolly, Ricardo Hoar, "Fundamentals of Web Development”, 1stEdition, Pearson
Education India. (ISBN:978-9332575271)
2. V S Code Application.
3. [Link]
4. [Link]
5. [Link]
6. [Link]
7. [Link].
8. [Link]
Dept. of ISE ,VKIT 2021-2022 Page 21