Webtechnologyies Final
Webtechnologyies Final
Proddatur
Prescribed For FOURTH SEMESTER
Department of Computer Engineering
Web Technologies
LABORATORY Manual
406-WEB TECHNOLOGIES LAB RECORD
Experiments Index:-
1.Exercise on Basic HTML Tags
2. Exercise on HTML Page Using Suitable Table Tags and Attributes.
3.Exercise on HTML Page using Form containing various controls.
4.Exercise on creating a HTML page using Frames.
5.Exercise on CSS.
7.Exercise on Javascript Functions.
8.Exercise on Javascript Arrays.
9.Exercise on mouse events using jquery.
10.Exercise on effects of jquery.
11.Exercise on changing the background color using .css() function in JQuery.
12.Exercise on ResponsiveSlides JQuery Plug-in.
13.Installation of XAMPP.
14.Exercise on PHP arrays.
15.Design a form and access the elements of form using PHP.
16.Various operations on a database table functions.
17.Write a PHP program to set a cookie.
1.Exercise on Basic HTML Tags
Bold Text:
Anything that appears within <b>...</b> element, is displayed in bold.
Syntax:-<b>.....</b>
Italic Text:
Anything that appears within <i>...</i> element is displayed in italicized.
Syntax:-<i>.....</i>
Underlined Text:
Anything that appears within <u>...</u> element, is displayed with underline.
Syntax:-<u>......</u>
Strike Text:
Anything that appears within <strike>...</strike> element is displayed with
strikethrough, which is a thin line through the text.
syntax:-<strike>.......</strike>
Subscript Text:
The content of a <sub>...</sub> element is written in subscript; the font size
used is the same as the characters surrounding it, but is displayed half a character's
height beneath the other characters.Subscript text can be used for chemical formulas, like
H2O.
Superscript Text:
The content of a <sup>...</sup> element is written in superscript; the font
size used is the same size as the characters surrounding it but is displayed half a
character's height above the other characters.Superscript text can be used for maths
formulas , like X+Y2-Z3.
Larger Text:
The content of the <big>...</big> element is displayed one font size larger than the
rest of the text surrounding.
Smaller Text:
The content of the <small>...</small> element is displayed one font size smaller
than the rest of the text surrounding it .
Monospaced Font:
The content of a <tt>...</tt> element is written in monospaced font. Most of the fonts
are known as variable-width fonts because different letters are of different widths (for ex, the
letter 'm' is wider than the letter 'i'). In a monospaced font, each letter has the same width.
<q> tag:
to add a double quote within a sentence.
<strong> tag:
Anything that appears within <strong>...</strong> element is displayed as important text.
<cite> tag:
The text in the <cite>...</cite> element usually renders in italic.
<ins> tag:
Anything that appears within <ins>...</ins> element is displayed as inserted text.
<del> tag:
Anything that appears within <del>...</del> element, is displayed as deleted text
<em> tag:
Anything that appears within <em>...</em> element is displayed as emphasized text.
Marquee Tag:
Allow you to have formatted text running(Scrolling) across the screen over a color
background. One can display many different pieces of information all on one line.
Attributes of marquee tag:
1. Behavior:
○ Specifies the scrolling behavior.
○ Values:
■ scroll (default): Scrolls the content continuously.
■ slide: Content scrolls in and stops at the edge.
■ alternate: Content bounces back and forth.
2. Direction:
○ Specifies the direction of scrolling.
○ Values:
■ left (default): Scrolls from right to left.
■ right: Scrolls from left to right.
■ up: Scrolls from bottom to top.
■ down: Scrolls from top to bottom.
3. Scrollamount:
○ Specifies the speed of the scrolling content in pixels.
○ Example: <marquee scrollamount="10">.
4. Scrolldelay:
○ Specifies the delay (in milliseconds) between each scroll movement.
○ Example: <marquee scrolldelay="100">.
5. Loop:
○ Specifies the number of times the content will scroll.
○ Values:
■ A number (e.g., 3).
■ -1 (default): Scrolls indefinitely.
6. Width:
○ Specifies the width of the marquee (in pixels or percentage).
○ Example: <marquee width="50%">.
7. Height:
○ Specifies the height of the marquee (in pixels or percentage).
○ Example: <marquee height="100px">.
8. Bgcolor:
○ Specifies the background color of the marquee.
○ Example: <marquee bgcolor="yellow">.
9. Hspace:
○ Specifies the horizontal space (in pixels) around the marquee.
○ Example: <marquee hspace="20">.
10. Vspace:
○ Specifies the vertical space (in pixels) around the marquee.
○ Example: <marquee vspace="20">.
List Tags:-
1. <ul> (Unordered List):
○ Used to create lists with bullet points.
○ Attributes:
■ type: Specifies bullet style (disc, circle, square, none).
■ id: Assigns a unique identifier.
■ style: Adds inline CSS styling.
■ class: Links the list to a CSS class for styling.
2. <ol> (Ordered List):
○ Used to create numbered or lettered lists.
○ Attributes:
■ type: Specifies numbering style (1, a, A, i, I).
■ start: Sets the starting number/letter for the list.
■ reversed: Displays the list in descending order.
■ id: Assigns a unique identifier.
■ style: Adds inline CSS styling.
■ class: Links the list to a CSS class for styling.
3. <li> (List Item):
○ Defines individual items in <ul>, <ol>, or <menu> lists.
○ Attributes:
■ type: Specifies marker style when used within lists.
■ value: Sets the numeric value for a specific item in an <ol> list.
4.<menu> (Menu List):
○ Used for context menus or command lists.
○ Attributes:
■ type: Specifies the menu type (list, context, toolbar).
■ label: Provides a label for the menu.
5.<dl>
The <dl> tag in HTML is used to create a description list (previously called a
definition list). It organizes content into paired items, such as terms and their
corresponding descriptions.
Attributes
1. <dl>: Wraps the entire list.
2. <dt>: Represents the term.
3. <dd>: Represents the description or definition of the term.
Program:-
<html>
<head>
<title>Tags Demo</title>
</head>
<body>
This is a HTML program for all tags Demo
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
Physical formatting tags<br>
<b>This is in bold</b><br>
<u>This text is underlined</u><br>
<i>This is in italic</i><br>
<strike>strike through</strike><br>
H<sub>2</sub>o<br>
a<sup>2</sup>b<br>
Amit is in <big>Spain</big><br>
I think it is <small>wrong</small><br>
<tt>This word is a monospaced typeface</tt><br>
logical formatting tags<br>
<q>Amit is in Spain</q><br>
<strong>Good Morning Mam </strong><br>
<cite>Good morning</cite><br>
I want to drink<del>wine</del><ins>Maaja</ins><br>
Hi <em>friends</em>
Marquee tab<br>
<marquee bgcolor="green" loop="5" scrolldelay="15" width="1000">Hi
friends</marquee><br>
<marquee bgcolor="yellow" direction="right" Behaviour="alternate" Scrollamount="25"
height="25">Good morning</marquee><br>
<img src="C:\Users\gsury\OneDrive\Pictures\Saved Pictures\krishna.jpeg" hspace="1000"
vspace="1500"><br>
An ordered list<br>
<ol type="i">
<li>Tea</li>
<li>Coffee</li>
<li>Milk</li>
</ol>
An unordered list<br>
<ul type="square">
<li>Tea</li>
<li>Coffee</li>
<li>Milk</li>
</ul>
Description tag.<br>
<dl>
<dt>Cookie</dt>
<dd>a small piece of information stored on a client computer</dd>
<dt>CSS</dt>
<dd>Cascading style sheets in a simple mechanism for adding style.</dd>
<dt>HTML</dt>
<dd>Hyper Text markup Language.</dd>
</dl>
<p>This is a paragraph tool,at last good morning to everyone and see you later to all good
bye and thank you for giving this opportunity and once again thank you and sorry for any
mistakes if I have done in future.</p>
</body>
</html>
Output:-
Result:- The exercises on the basic HTML tags are performed successfully.
2.EXERCISE ON HTML PAGE To display Time Table USING SUITABLE TABLE TAGS
AND ATTRIBUTES
Aim:Exercise on basic HTML tags.
Required software and hardware:
Personal computer with VS code or notepad with browser.
Theory:
Table Tags and Attributes
1. <table> (Table)
● Defines a table to organize data.
● Common Attributes:
○ align: Aligns the table relative to the surrounding text (left, center, right).
○ bgcolor: Sets the background color of the table using color names, RGB
values, or hex codes.
○ border: Specifies the border width of the table.
○ cellpadding: Sets the space between the cell content and its walls (in pixels).
○ cellspacing: Sets the space between adjacent cells (in pixels).
2. <tr> (Table Row)
● Used to define a row in a table.
● Common Attributes:
○ align: Aligns the content horizontally within the row (left, right, center, justify,
char).
○ bgcolor: Sets the background color of the row.
○ valign: Aligns the content vertically (top, middle, bottom, baseline).
○ cellpadding and cellspacing: Same functionality as in <table>; can be
overridden for specific rows.
3. <th> (Table Header Cell)
● Defines a header cell in the table. By default:
○ Content is bold and centered.
● Shared Attributes with <td>:
○ colspan: Merges the cell across multiple columns.
○ rowspan: Merges the cell across multiple rows.
○ height: Sets the height of the cell.
○ width: Sets the width of the cell.
4. <td> (Table Data Cell)
● Defines a regular data cell in the table.
● Attributes:
○ Same as <th>, including colspan, rowspan, height, and width.
Program:-
<html>
<head>
<title>Time Table</title>
</head>
<body>
<table border="5" cellpadding="10">
<caption><h1><u><i>4<sup>th</sup>Semester time table</i></u></u></h1></caption>
<tr bgcolor="yellow">
<th><b>Branch</b></th>
<th><b>Day</b></th>
<th><b>1(9:30AM-10:20AM)</b></th>
<th><b>2(10:20AM-11:10AM)</b></th>
<th><b>3(11:20AM-12:10PM)</b></th>
<th><b>4(12:10 PM-01:00PM)</b></th>
<th><b>(01:00 PM-02:00 PM)</b></th>
<th><b>4(02:00 PM-02:50 PM)</b></th>
<th><b>4(02:50 PM-03:40 PM)</b></th>
<th><b>4(03:40 PM-04:30 PM)</b></th>
</tr>
<tr align="center" border="4">
<td rowspan=10 bgcolor="green"><h1>Computer Engineering</h1></td>
<td bgcolor="red"><h3>Monday</h3></td>
<td colspan="2"><b>CM-405(CN)</b></td>
<td colspan="2"><b>CM-402(Web Technology)</b></td>
<td rowspan="6" bgcolor="blue" valign=”middle”><h2><b>Lunch Break</b></h2></td>
<td colspan="3"><b>CM-408(Communication Lab)</b></td>
</tr>
<tr align="center" border="4">
<td bgcolor="red"><h3>Tuesday</h3></td>
<td colspan="2"><b>CM-401(SE)</b></td>
<td><b>CM-404(Java)</b></td>
<td><b>CM-407(Java Lab)</b></td>
<td colspan="3"><b>CM-407(Java Lab)</b></td>
</tr>
<tr align="center" border="4">
<td bgcolor="red"><h3>Wednesday</h3></td>
<td colspan="2"><b>CM-403(CO&M)</b></td>
<td colspan="2"><b>CM-402(Web Technology)</b></td>
<td><b>CM-401(SE)</b></td>
<td colspan="2"><b>CM-404(Java)</b></td>
</tr>
<tr align="center" border="4">
<td bgcolor="red"><h3>Thursday</h3></td>
<td colspan="2"><b>CM-405(CN)</b></td>
<td colspan="2"><b>CM-404(Java)</b></td>
<td colspan="3"><b>CM-409(CN Lab)</b></td>
</tr>
<tr align="center" border="4">
<td bgcolor="red"><h3>Friday</h3></td>
<td colspan="4"><b>CM-406(Web Technology Lab)</b></td>
<td colspan="2"><b>CM-403(CO&M)</b></td>
<td><b>CM-401(SE)</b></td>
</tr>
<tr align="center" border="4">
<td bgcolor="red"><h3>Saturday</h3></td>
<td><b>CM-405(CN)</b></td>
<td><b>CM-402(Web Technology)</b></td>
<td><b>CM-401(SE)</b></td>
<td><b>CM-403(CO&M)</b></td>
<td colspan="3"><b>Activities</b></td>
</tr>
</table>
</body>
</html>
Output:-
Result:-The above HTML program on HTML page using the suitable table tags and its
attributes are verified successfully.
Output:
Result:
The above HTML program on the HTML page using Form containing various controls are
verified successfully.
4.Exercise on creating a HTML page using Frames
Aim:To create a HTML page using frames.
Required software and hardware:
Personal computer with VS code or notepad with browser.
Theory:
Frameset Tag (<frameset>)
The <frameset> tag is used to divide the browser window into multiple sections called
frames, where each frame can load a separate HTML document.
Attributes:
● cols: Specifies the number and size of columns in the frameset.
Example: cols="100, 500, 100" creates three vertical frames with widths of 100px,
500px, and 100px.
Percentages: cols="10%, 80%, 10%"
Remainder: cols="10%, 80%, *"
● rows: Specifies the number and size of rows in the frameset.
Example: rows="100, 500, 100" creates three horizontal frames with heights
of 100px, 500px, and 100px.
Percentages: rows="10%, 80%, 10%"
Remainder: rows="10%, 80%, *"
● border: Specifies the width of the border between frames in pixels.
Example: border="5" sets a 5-pixel border.
border="0" removes the border.
● frameborder: Determines whether a 3D border appears around frames.
Values: 1 (yes), 0 (no)
Example: frameborder="0"
● framespacing: Sets the space between frames within a frameset.
FRAME1.HTML:
<html >
<head>
<title>YouTube Mockup</title>
</head>
<body>
<form >
<img src="youtubelogo.jpg" height="25" width="100"><label for="search">Search</label>
<input type="text" id="search" name="search">
<button type="submit">Search</button>
|<a href="#">Browse</a>|
<a href="#">Upload</a>
<a href="#">Create Account</a>|
<a href="#">Sign In</a>
</form>
</body>
</html>
FRAME2 P1.html
<!doctype html>
<html>
<head>
<title>video </title>
</head>
<body>
<h1>Urime Manase from Ninnu kori movie </h1>
<video controls width="100%" height="400">
<source src="https://res.cloudinary.com/degpbxpd2/video/upload/v1735230616/
Krishnarjuna_Yuddham_Video_songs__Urime_Manase_Video_Song___Nani_Anupama_R
ukshar___Hiphop_Tamizha_mnt6sa.mp4" type="video/mp4">
</video>
</body>
</html>
FRAME2 P2.html
<html>
<head>
</head>
<body>
<br>Urime Manase from Ninnu Kori movie Full video song HD(1080p)
<p>Uploaded by <a href="#">surya </a> on feb 22,2022</p>
<p><strong>135,135 views</strong></p> <button>Like</button> <button>Add to</button>
<button>Share</button> <button>download</button>
<h5><u><strong> DESCRIPTION</strong></u></h2><p>For more videos follow our
channel<br></p>
<br><br>
<iframe src="add.html" length="300" width="400">
</iframe>
</body>
</html>
FRAME3.HTML
<html>
<head></head>
<body>
<h1> Suggestions </h1> <br>
<video controls width="200" height="125">
<source src="https://res.cloudinary.com/degpbxpd2/video/upload/v1735231265/
Who_Are_You_-
_4K_Video_Song___1Nenokkadine___Mahesh_Babu_Kriti_Sanon___DSP___Sukumar___
Chandra_Bose_kr0pq4.mp4" type="video/mp4"></video>
Who are you ||DSP||MAHESH<br>
main lab.html:
<html>
<head>
</frameset>
<frame src="FRAME3.HTML">
</frameset>
</frameset>
<noframes>
<p>This browser does not support frames.</p>
</noframes>
</html>
Output:
Result:The above HTML program using frames has been executed successfully.
5.Exercise on CSS
Aim:To create a HTML page using CSS styles.
Required software and hardware:
Personal computer with VScode or notepad with browser.
Theory:
There are three ways to inserting a style sheet:
1. Inline style sheet
2. Internal style sheet
3. External style sheet
CSS syntax:
hi {
color: blue;
font-size:12px;
}
Selectors:
1. Element selector: This selector selects HTML elements directly based on element name.
Syntax:
element {
/* css properties */
}
4. Class selector: This selector selects HTML elements using .class attribute.
Syntax:
.class {
/* css-properties */
}
5. Universal selector: This selector selects all the HTML elements in a page.
Syntax:
*{
/* css-properties */
}
Color Properties:
Attributes:
- color: Sets foreground color of text of an HTML element.
- background-color: Sets background color of an HTML element.
- Value: auto / cover / contain.
- background-attachment: Controls scrolling of background image.
Syntax: background-attachment: value;
Values: scroll / fixed
- background: Combines all background properties in one declaration.
Syntax: background: color image repeat attachment Position(size).
Borders Properties:
Attributes:
- border-style: Sets type of border is displayed.
Syntax: border-style: value;
Values: dotted / dashed / Solid / double / none.
- border-width: Sets the width of four borders.
Syntax: border-width: value;
Values: thin / medium / thick.
- border-color: Sets color in four borders.
Syntax: border-color: value;
- border: Sets all properties at once.
Background Properties:
Attributes:
- background-color: Element's background color.
- background-image: Sets an image as the background.
- background-repeat: Repeats the background image.
Values: repeat-X / repeat-y / repeat(default) / no-repeat.
- background-size: Defines the size of the background image.
- background-position: Position of the background image.
Values: Left / Right / Center / Top / Bottom.
Padding Properties:
- padding-top: Gives space between content and its top border.
- padding-bottom: Gives space between content and its bottom border.
- padding-right: Gives space between its right border and content.
- padding-left: Gives space between content and its left border.
- padding: Gives space between content and borders of four sides.
Margin Properties:
- margin-top: Gives space between element and its top side surrounding content.
- margin-bottom: Gives space between element and its bottom side surrounding content.
- margin-right: Gives space between element and its right side surrounding content.
- margin-left: Gives space between element and its left side surrounding content.
- margin: Gives space between elements and all its surrounding content.
Position Property:
Position Property is used to define the position of HTML elements in a webpage.
Syntax: Position: value;
Values:static/ relative/ absolute/ fixed/ sticky
Source code:
//CSS Code:-
p
{
font-size: larger;
font-style:oblique;
background-color:rgb(61, 222, 211);
}
//HTML Code:-
<!DOCTYPE html>
<html>
<head>
<title>experiment:5</title>
<link rel="stylesheet" type="text/css" href="external.css">
<style>
p,h1
{
text-align: center;
font-size: 40px;
font-variant:small-caps;
font-style:normal;
position: sticky;
}
h1.one
{
border-top: double;
border-left:dotted;
border-right: dotted;
border-bottom:solid ;
border-color: rgb(42, 165, 91);
position:sticky;
}
h1.two
{
border-top:solid ;
border-left:dotted ;
border-right:double ;
border-bottom: solid;
border-radius: 10px;
position: sticky;
}
h1.three
{
border-top-style: dotted;
border-right-style: solid;
border-bottom-style: dotted;
border-left-style: solid;
border-color: blue;
position:static;
}
#para1
{
font-size: 70px;
color: blue;
position: sticky;
border-style: dotted;
border-radius:100px;
padding: 10px 10px;
margin: 25px;
border:100px solid green;
}
body{
background-image:url("https://media.istockphoto.com/id/1068830604/photo/abstract-blurred-
beautiful-interior-of-lobby-reception-condominium-background-with-bokeh.jpg?
s=612x612&w=0&k=20&c=_vjkk1TfLTlLstBH_Sug_saKem2wz3u6fSigYNAzWAo=");
background-repeat: repeat-y;
background-position: right top;
background-size:contain;
background-attachment:fixed ;
}
h1.four{
margin:10px 20px 30px 40px;
padding: 80px;
border: 1px solid black;
}
.parent{
position:relative;
width:1000px;
height:500px;
border:2px solid black;
font-size:80px;
border-color: brown;
}
.child{
position:absolute ;
top:200px;
left:250px;
width:300px;
height:200px;
border:2px dashed YELLOW;
font-size: 35px;
border-color: RED;
}
h3{
position: sticky;
top: 0;
TEXT-align:CENTER;
}
</style>
</head>
<body>
<p id="para1" STYLE="POSITION:FIXED;">cascading style sheets</p>
<h3>cascading style sheets</h3>
<h2> GOVERNMENT POLYTECHNIC COLLEGE, PRODDATUR.</h2>
<h1 class="one" STYLE="background-color:"BLUE";">Inline Style</h1>
<p STYLE="FONT-SIZE:20PX;background-color:"YELLOW";"><h2> The CSS that is
applied directly within an html element using <b>style</b> attribute is called INLINE
CASCADING STYLE SHEETS
.It is suitable to give unique styles to a single html element.</h2></p><br>
<h1 class="two">Internal Style</h1>
<p><h2>An internal/embedded style sheet is a stylesheet where css styles are applied to
html elements using a style tag which is placed under the head section of the html
document.</h2></p>
<h1 class="three" >External Style</h1>
<p><h2>An external/global cascading style sheet is a style sheet document written
separately from an html document and is linked to the html document using link
tag.</h2></p><br>
<h1 class="four">GOOD MORNING</h1>
<div class="parent">RESPECTED TEACHERS AND MY DEAR FRIENDS
<div class="child">THANK YOU EVERYONE</div>
</div>
</body>
</html>
OUTPUT:-
Result:The above HTML program using css has been executed successfully.
5.Exercise on Designing an XML document.
Aim:To create a HTML on designing an XML document.
Required software and hardware:
Personal computer with VS code or notepad with browser.
Theory:
Extensible Markup Language (XML) is a markup language designed for storing and
transporting data. It is both human-readable and machine-readable, making it ideal for data
interchange between different systems.
Key Features:
- *Self-descriptive*: XML uses custom tags to describe data, making it easy to understand.
- *Extensible*: Users can create their own tags, allowing flexibility for various applications.
- *Well-formed and Valid*: XML documents must follow specific syntax rules to be
considered well-formed and can conform to a schema for validation.
Applications:
- *Data Interchange*: Facilitates communication between different software systems.
- *Document Storage*: Organizes and stores information in a structured format.
- *Configuration Files*: Used by applications to define settings and preferences.
Sample Program:
Output:
Result:
The above XML program has been executed successfully.
7.Exercise on Javascript Functions
2.Output
For live Demonstration click here:click here
Source code:
<html>
<head>
<style>
#dis{
color:rgb(38, 47, 145);
}
body{
background-color:rgb(243, 205, 231) ;
}
</style>
</head>
<body>
<h1 align="center"> ARRAYS SORTING</h1>
Enter a array Element:
<input type="number" id="value">
<button onclick="push()">ADD</button><br>
<p id="dis"></p>
<button onclick="sortArray()">Alphabetic SORT(ASC) </button>
<button onclick="sortdesc()">Alphabetic SORT(DESC)</button>
<button onclick="nacc()">Numeric SORT(ASC)</button>
<button onclick="ndec()">Numeric SORT(DESC)</button>
<p id="demo"></p>
<p id="des"></p>
<script>
let array=[ ];
function push(){
array.push(document.getElementById("value").value);
document.getElementById("value").value="";
Output:
1.Alphabetic Ascending Sort function:
Source Code:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<title>Mouse events</title>
<style>
div {
padding:1px;
text-align:center;
background-color:pink;
border:solid 2px red;
margin:100px;
}
</style>
</head>
<body>
<div><h1><p id="key">Original Text</p></h1></div>
<script>
$(document).ready(function()
{
$("div").mouseenter(function(){
$("#key").text("Mouse Entered");
});
$("div").mouseleave(function(){
$("#key").text("Mouse Leave");
});
$("#key").mouseup(function(){
$("#key").text("Mouse Up");
});
$("#key").mousedown(function(){
$("#key").text("Mouse Down");
});
$("#key").mouseover(function(){
$("#key").text("Mouse Over");
});
$("#key").mouseout(function(){
$("#key").text("Mouse Out");
});
$("#key").dblclick(function(){
$("#key").text(" Mouse Double Clicked");
});
$("#key").click(function(){
$("#key").text("Mouse Clicked");
})
});
</script>
</body>
</html>
Output:
10.Effects of JQuery
Aim:To create a HTML webpage to apply the effects of Jquery.
Required software and hardware:
Personal computer with VS code or notepad with browser.
Theory:
1. Show/Hide Methods
These methods control the visibility of elements.
hide():Hides the selected element.
Syntax:hide(speed, callback)
● The speed parameter can be "slow", "fast", or a number in milliseconds.
● The callback is optional and executes after hiding is complete.
show():Displays the hidden element with an optional animation speed and callback
function.
Syntax:show(speed, callback)
toggle().Toggles the visibility of the selected elements.
Syntax:toggle(speed, callback)
● If the element is visible, it hides; if hidden, it shows.
2. Fade Methods
These methods change the opacity of elements gradually.
fadeIn():Changes the opacity of selected elements from hidden to visible.
Syntax:fadeIn(speed, callback)
fadeOut():Gradually reduces the opacity of selected elements to 0 and then sets
display: none.
Syntax:fadeOut(speed, callback)
fadeTo():Adjusts the opacity of the selected element to a specific value between 0
and 1.
Syntax:fadeTo(speed, opacity, callback)
3. Slide Methods
These methods create smooth sliding animations.
slideDown():Reveals the hidden element by sliding it down.
Syntax:slideDown(speed, callback)
slideUp(speed, callback):Hides the element by sliding it up.
Syntax:slideUp(speed, callback)
slideToggle():Toggles between slideDown() and slideUp().
Syntax:slideToggle(speed, callback)
Source Code:
<html>
<head>
<title>JQuery Effects</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<style>
div{
border:5px solid lightgrey;
padding:5px;
background-color:pink;
}
.button{
border:none;
color:white;
padding:15px 32px;
text-align:center;
text-decoration:none;
display:inline-block;
font-size: 16px;
margin:4px 2px;
cursor:pointer;
}
.button1{background-color: #04aa6d;}
.button2{background-color: #008cba;}
</style>
<script>
$(document).ready(function(){
$("#hide").click(function(){
$("#p1").hide(1000);
});
$("#show").click(function(){
$("#p1").show(1000);
});
$("#toggle").click(function(){
$("#p1").toggle(1000);
});
$("#fadeout").click(function(){
$("#p2").fadeOut();
});
$("#fadein").click(function(){
$("#p2").fadeIn(1000);
});
$("#fadetol").click(function(){
$("#p2").fadeTo("slow",0.2);
});
$("#fadetoh").click(function(){
$("#p2").fadeTo("slow",1);
});
$("#slidedown").click(function(){
$("#p3").slideDown();
});
$("#slideup").click(function(){
$("#p3").slideUp();
});
$("#slidetoggle").click(function(){
$("#p3").slideToggle();
});
});
</script>
</head>
<body>
<h1><br/><div id="p1" align="center">jQuery Effects - Hide, Show</div></h1>
<button class="button button1" id="hide">Hide</button>
<button class="button button1" id="show">Show</button>
<button class="button button1" id="toggle">Toggle</button>
3.Fade to 0.2:
Result:The above program has been executed successfully.
11. CHANGING CSS PROPERTIES IN JQUERY
<body>
<h1><div id="div1">Demonstration on Changing border,font,backgroungcolor,etc using
CSS properties in jQuery</div></h1>
<br><input class="button button1" id="btnBorder" type="button" value="change border"/>
<input class="button button2" id="btnColor" type="button" value="change font color"/>
<input class="button button1" id="btnFont" type="button" value="click to change font"/>
<input class="button button2" id="btnBColor" type="button" value="change background
color"/>
</body>
</html>
Output:-
Before clicking any of the buttons:
After clicking all the buttons:
Source code:-
//HTML code:
<!DOCTYPE html>
<html>
<head>
<title>Responsive Image Slide Show using jQuery</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="responsiveslides.css">
<link rel="stylesheet" href="style.css">
<script src="jquery-3.2.1.min.js"></script>
<script src="responsiveslides.min.js"></script>
<script>
$(function () {
$("#slider").responsiveSlides({
auto: true,
pager: false,
nav: true,
speed: 300,
namespace: "slider-callback",
maxwidth: "550px"
});
});
</script>
</head>
<body>
<h2>Famous places in india </h2>
<div id="wrapper">
<div class="responsive-slider">
<ul class="rslides" id="slider">
<li>
<img
src="https://res.cloudinary.com/degpbxpd2/image/upload/v1739516769/32ddb97d-a424-
4374-9681-3b10d3f08227.png" alt="">
<p class="caption">lepakshi</p>
</li>
<li>
<img src="https://res.cloudinary.com/degpbxpd2/image/upload/v1739516599/
ddb6e472-441b-4a57-8162-4ec0511ae6b6.png" alt="">
<p class="caption">charminar</p>
</li>
<li>
<img src="https://res.cloudinary.com/degpbxpd2/image/upload/v1739516430/
eed80a6d-d2bf-4c29-b324-b3c5f1b87a5d.png" alt="">
<p class="caption">gandikota</p>
</li>
<li>
<img
src="https://res.cloudinary.com/degpbxpd2/image/upload/v1739516336/9b231997-1e17-
418f-98cf-845532f6ede7.png" alt="">
<p class="caption">Taj mahal</p>
</li>
<li>
<img
src="https://res.cloudinary.com/degpbxpd2/image/upload/v1739516314/08a5be76-5225-
49cb-823e-e87139145306.png" alt="">
<p class="caption">Red fort</p>
</li>
</ul>
</div>
</div>
</body>
</html>
//CSS code:-
.rslides {
position: relative;
list-style: none;
overflow: hidden;
width: 100%;
padding: 0;
margin: 0;
}
.rslides li {
-webkit-backface-visibility: hidden;
position: absolute;
display: none;
width: 100%;
left: 0;
top: 0;
}
.rslides li:first-child {
position: relative;
display: block;
}
.rslides img {
display: block;
height: 50%;
float: left;
width: 100%;
border: 0;
}
.next {
margin-left: 450px;
}
Output:
Result:-The above program executed successfully.
● My SQL
● Embedded in HTML – PHP code is mixed with HTML for dynamic content
generation.
● Database Support – Works with MySQL, PostgreSQL, MongoDB, and more.
● Secure & Scalable – Provides encryption, session handling, and scalability for large
applications.
Apache Web Server
● Purpose: Handles HTTP requests and serves web pages.
● Key Features: Fast, scalable, secure, and widely used in web applications.
● Usage: Works with PHP for dynamic content (e.g., user authentication, e-
commerce).
XAMPP (Local Server Environment)
● Purpose: Provides an easy way to develop and test web applications locally.
● Components:
o Apache (Web Server)
o MySQL (Database)
o PHP (Scripting Language)
o phpMyAdmin (Database GUI)
● Why Use?: Pre-configured, cross-platform, and ideal for beginners.
Procedure:-
XAMPP is the most popular PHP development environment.
XAMPP is a completely free, easy to install Apache distribution containing MariaDB, PHP,
and Perl. The XAMPP open source package has been set up to be incredibly easy to install
and to use.
1. Go to the official XAMPP website
2. Click on the appropriate OS of yours and now the XAMPP installer file will start
downloading in 5 seconds.
3. Run .exe file
When you download the software package, you can start the XAMPP installation.
Double-click on the file ending with the .exe file.
4.Click Next to start the procedure.
5. Select all components and then click Next.
6. Select the folder to install XAMPP and click Next. It is recommended to install the
software into the default folder.
7.Untick the Learn more about Bitnami for XAMPP checkbox and click Next.
10.Check that the Do you want to start the Control Panel now? checkbox is ticked and
click Finish.
11.Now open the XAMPP software.
12.Now start the required modules(we started apache and MySQL below) Green
background around Apache and MySQL marks that these modules work correctly.
13.In the browser address line enter localhost. If you see the Welcome to XAMPP for
Windows! notification, the environment is set up and ready for work.
14.PHP arrays
Aim: To create a php program to demonstrate the different types of arrays in php.
Required software and hardware:
Personal computer with VS code or notepad with browser.
Theory:-
Types of Arrays in PHP
● Arrays in PHP are used to store multiple values in a single variable.
● The elements of an array may have different data types.
PHP provides three main types of arrays:
1. Indexed Arrays:
Indexed arrays store elements with a numeric index, which starts from 0. These are
used when you need to store a simple list of values. The elements can be accessed using
their index numbers.
Syntax:
$array = array(value1, value2, value3);
echo $array[index];
2. Associative Arrays:
Associative arrays use named keys instead of numeric indexes. These are useful
when data needs to be stored with specific keys for better readability and access. The keys
act as identifiers for the values.
Syntax:
$array = array("key1" => value1, "key2" => value2);
echo $array["key"];
3. Multidimensional Arrays:
Multidimensional arrays contain other arrays as their elements. These are used to
represent complex data structures, like tables or matrices. They can have multiple levels
(nested arrays), allowing data to be organized hierarchically.
Syntax:
$array = array(
array(value1, value2),
array(value3, value4)
);
echo $array[row][column];
Program:-
<!DOCTYPE html>
<html>
<body>
<?php
//associative arrays
$a=array("a"=>"red","b"=>"green","c"=>"blue");
$temp="red";
echo "Associative Array : ";
var_dump($a);
echo "<br>";
$c=in_array($temp, $a);
echo "Red exists in the associative array? " . ($c ? "Yes" : "No") . "<br>";
echo "Key of red is: ".array_search("red",haystack: $a)."<br><br>";
//multidimensional arrays
$b=array(
array(5,7,8,9,2,3,1),
array(2,9,8,5,0,2,6),
array(8,2,3,4,8,6,7));
echo "Multi Dimensional Array :".'($b)'."<br>";
$smallest =$b[0][0];
foreach ($b as $subArray) {
foreach ($subArray as $value) {
echo "$value ";
if ($value < $smallest) {
}
}
echo"<br>";
}
for ($t = 0; $t < count($b); $t++) {
for ($j = 0; $j < count($b[$t]); $j++) {
if ($b[$t][$j] < $smallest) {
$smallest = $b[$t][$j];
$index=[$t,$j];
}
}
}
echo "<br>The smallest number in the multidimensional array is: ".$smallest;
echo "<br>The index of smallest number '$smallest' ".'in array $b is ';
echo '['.$index[0].']['.$index[1].']';
?>
</body>
</html>
Output:-
Aim: To design a form and access the elements of form and access the elements of the
form using PHP.
Required software and hardware:
Personal computer with VS code or notepad with browser.
Theory:-
PHP Form Handling
PHP form handling is a crucial aspect of web development, enabling interaction
between users and a web server. When a user submits a form, the data is sent to the server
for processing. PHP uses superglobal variables such as $_GET and $_POST to collect
form data, depending on the request method used.
GET Method
The GET method sends form data as a part of the URL in query parameters. It is
commonly used for retrieving information, such as search queries or filtering options.
Characteristics of GET:
● Data is appended to the URL, making it visible in the browser’s address bar.
● Has a character limit (~2048 characters).
● Can be bookmarked and stored in browser history.
● Less secure, as data remains in the browser cache and can be seen in logs.
● Used when sensitive data is NOT involved.
Example Use Case:
● Search forms (search?q=php+tutorial)
● Filtering products on an e-commerce website
POST Method
The POST method sends data within the HTTP request body, making it invisible in
the URL. It is used when transmitting sensitive or large amounts of data.
Characteristics of POST:
● Data is not exposed in the URL, making it more secure than GET.
● No character limit, allowing large form submissions.
● Cannot be bookmarked or stored in browser history.
● Supports file uploads and complex form submissions.
● Used when handling sensitive information.
Example Use Case:
● Login forms (username & password)
● Contact forms
● File uploads
Program 1:(getpostfinal.php):-
<?php
$resultp = "";
$resultg = "";
switch ($operation) {
case "add":
$resultp =" $num1 + $num2 = ".($num1+$num2);
break;
case "subtract":
$resultp =" $num1 - $num2 = ".($num1-$num2);
break;
case "multiply":
$resultp =" $num1 * $num2 = ".($num1*$num2);
break;
case "divide":
if ($num2 != 0) {
$resultp =" $num1 / $num2 = ".($num1/$num2);
} else {
$resultp = "Cannot divide by zero!";
}
break;
default:
$resultp = "Invalid operation";
}
}
echo "The form elements are accessed using<b> POST </b> method<br>The result of
$resultp";
}
switch ($operation) {
case "add":
$resultg =" $num1 + $num2 = ".($num1+$num2);
break;
case "subtract":
$resultg =" $num1 - $num2 = ".($num1-$num2);
break;
case "multiply":
$resultg =" $num1 * $num2 = ".($num1*$num2);
break;
case "divide":
if ($num2 != 0) {
$resultg =" $num1 / $num2 = ".($num1/$num2);
} else {
$resultg = "Cannot divide by zero!";
}
break;
default:
$resultg = "Invalid operation";
}
echo "The form elements are accessed using <b>GET</b> method<br>The result of
$resultg";
}
}
?>
Program 2:(getpostfinal.html):-
<html>
<head>
<title>PHP Calculator</title>
</head>
<body>
</body>
</html>
Output:-(getpostfinal.html)
Result:-The form elements accessing using the PHP are successfully executed.
16.Exercise on database table using functions
Aim: To perform CRUD operations on database table using database functions in PHP
Required software and hardware:
Personal computer with VS code or notepad with browser.
Theory:-
● PHP provides built-in functions to connect, manipulate, and manage MySQL
databases efficiently. MySQL is one of the most popular database management
systems used alongside PHP.
● In MySQL, data is stored in tables, which consist of rows (records) and columns
(fields). PHP interacts with MySQL using the MySQLi (MySQL Improved)
extension.
Connecting PHP to MySQL
● Before performing any database operations, we must establish a connection to the
MySQL server. PHP provides the mysqli_connect() function to achieve this.
PHP MySQL Procedural Methods
1. Connecting to MySQL
$connection = mysqli_connect(servername, username, password, dbname);
if (!$connection) {
die("Connection failed: " . mysqli_connect_error());
}
2. Closing the Connection
mysqli_close($connection);
3. Handling Connection Errors
mysqli_connect_error();
4. Executing a Single Query
mysqli_query(connection, query);
5. Executing Multiple Queries
mysqli_multi_query(connection, query);
6. Creating a Database
$query = "CREATE DATABASE dbname";
mysqli_query($connection, $query);
7. Creating a Table
$query = "CREATE TABLE table_name (column1 datatype, column2 datatype, ...)";
mysqli_query($connection, $query);
8. Inserting Data
$query = "INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...)";
mysqli_query($connection, $query);
9. Retrieving Data
$query = "SELECT column_name(s) FROM table_name";
$result = mysqli_query($connection, $query);
10. Fetching Data from Result
$row = mysqli_fetch_assoc(result);
11. Updating Data
$query = "UPDATE table_name SET column1 = value1 WHERE condition";
mysqli_query($connection, $query);
12. Deleting Data
$query = "DELETE FROM table_name WHERE condition";
mysqli_query($connection, $query);
Program:-
<html>
<head><title>PHP</title></head>
<body>
<?php
$servername="localhost";
$username="prashanth";
$password="abc";
$conn=mysqli_connect($servername,$username,$password);
if(!$conn){
die("connection failed:".mysqli_connect_error());
}
else{
echo "Connection established successfully<br>";
}
$sql="CREATE DATABASE sample";
$database="sample";
if(mysqli_query($conn,$sql))
{
echo "DataBase '".$database."' Created Successfully<br>";
}else{
echo "Error in database creation:".mysqli_error($conn);
}
$conn=mysqli_connect($servername,$username,$password,$database);
$table="CREATE TABLE student(
pin INT(10) PRIMARY KEY,
s_name VARCHAR(50) NOT NULL,
age INT(2) NOT NULL,
phone_no BIGINT(15)
)";
if(mysqli_query($conn,$table)){
echo "Table 'Student' created Successfully<br><br>";
}
else{
echo "error in table creation:".mysqli_error($conn);
}
$ins1="INSERT INTO student VALUES(13,'Kumar',18,9014581033)";
if(mysqli_query($conn,$ins1)){
echo "In 'student' table one row inserted <br>";
}else{
echo "error in data insertion:".mysqli_error($conn);
}
echo "Table data is<br>";
$sel=mysqli_query($conn,"SELECT *FROM student");
if(mysqli_num_rows($sel)>0){
while($row = mysqli_fetch_array($sel)){
echo "PIN:".$row["pin"]."--Name:".$row["s_name"]."--Age:".$row["age"]."--Phone
no:".$row["phone_no"]."<br>";
}
}
else {
echo "0 results<br>";
}
Result:-The various database functions are explained and CRUD operations performed on
database tables successfully.
17.Cookie
Aim: To create and destroy a cookie in PHP
Required software and hardware:
Personal computer with VS code or notepad with browser.
Theory:-
PHP Cookies:-
A cookie is often used to identify a user. A cookie is a small file that the server
embeds on the user's computer. Each time the same computer requests a page with a
browser, it will send the cookie too. With PHP, you can both create and retrieve cookie
values.
Create Cookies With PHP:-
A cookie is created with the setcookie() function.
Syntax:- setcookie(name, value, expire, path, domain, secure, httponly);
Note:
● The setcookie() function must appear BEFORE the <html> tag.
● The value of the cookie is automatically URLencoded when sending the cookie, and
automatically decoded when received (to prevent URLencoding, use setrawcookie()
instead).
Modify a Cookie Value:-
To modify a cookie, just set (again) the cookie using the setcookie() function:
Delete a Cookie:-
To delete a cookie, use the setcookie() function with an expiration date in the past:
Check if Cookies are Enabled:-
The following example creates a small script that checks whether cookies are
enabled. First, try to create a test cookie with the setcookie() function, then count the
$_COOKIE array variable.
Program:-
<?php
$cookie_name="";
$cookie_value="";
if($_SERVER["REQUEST_METHOD"] == "POST"){
if(!empty($_POST["cname"]) && !empty($_POST["cvalue"])){
$cookie_name=$_POST["cname"];
$cookie_value=$_POST["cvalue"];
//creation of cookie
setcookie($cookie_name,$cookie_value,time()+(86400*30),"/");
header("Location: " . $_SERVER['PHP_SELF']);
exit();
}
}
if($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["destroy"]) &&
isset($_POST["cdname"]) && !empty($_POST["cdname"]))
{
setcookie($_POST["cdname"],"",time()-36000,"/");
header("Location: " . $_SERVER['PHP_SELF']);
exit();
}
?>
<html>
<head><title>PHP Cookies</title>
</head>
<body>
<h3>Creating a cookie</h3>
<form method="POST">
Enter the name for the cookie<input type="text" name="cname"><br>
Enter the value for the cookie<input type="text" name="cvalue"><br>
<input type="submit">
</form>
<form method="POST"><br>
<h3> Destroying a Cookie:</h3><br>
Enter the name for the cookie<input type="text" name="cdname" required><br>
Click to destroy cookie<button name="destroy">Click to destroy</button>
</form>
<?php
if(!empty($_COOKIE))
{
echo "Existing cookies : <br>";
foreach ($_COOKIE as $key => $value) {
echo "Cookie Name: '" . $key . "' is set.<br>";
echo "Its Value is: " .$value . "<br><br>";
}
} else {
echo "No cookies are set.";
}
?>
</body>
</html>
Output:-