0% found this document useful (0 votes)
13 views9 pages

PHP Lab Programs CZCA

The document contains several HTML programs demonstrating various functionalities including text formatting with images and hyperlinks, creating a student marks sheet, string manipulation using PHP, performing arithmetic operations with JavaScript, and evaluating mathematical expressions. Each program has a specific aim and includes source code along with expected outputs. The examples illustrate the use of HTML, CSS, JavaScript, and PHP to achieve different tasks.

Uploaded by

janabuchupati
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)
13 views9 pages

PHP Lab Programs CZCA

The document contains several HTML programs demonstrating various functionalities including text formatting with images and hyperlinks, creating a student marks sheet, string manipulation using PHP, performing arithmetic operations with JavaScript, and evaluating mathematical expressions. Each program has a specific aim and includes source code along with expected outputs. The examples illustrate the use of HTML, CSS, JavaScript, and PHP to achieve different tasks.

Uploaded by

janabuchupati
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/ 9

Programe 1:

Write a HTML program to demonstrate text formatting working with Image and Hyperlinks.

Aim: To write an HTML program to demonstrate text formatting working with Image and
Hyperlinks.
Source Code :

<!DOCTYPE html>
<html>
<head>
<title>Formatting Text in HTML</title>
</head>
<body align="center">
<p>This is <b>Bold text</b></p>
<p>This is <strong>Strong text</strong></p>
<p>This is <i> This is Italic Text</i></p>
<p>This is <em> Emphasised text</em></p>
<p>This is <code>computer code</code></p>
<p>This is <small>Smaller text</small></p>
<p>This is <sub>subscripted Text</sub></p>
<p>This is <sup>superscripted Text</sup></p>
<p>This is <del> Deleted Text</del></p>
<p>This is <ins>Inserted Text</ins></p>
<p>This is hyperlink<a href="https://loyoladegreecollegeysrr.ac.in/'' >Click here
</a></p>
<p>This is image <img
src="C:\Users\user\Downloads\pexels-fbo-media-17331157.jpg" alt="picture of car">
</p>
</body>
</html>

Output :

This is Bold text

This is Strong text

This is This is Italic Text

This is Emphasised text

This is computer code

This is Smaller text

1
This is subscripted Text

This is superscripted Text

This is Deleted Text

This is Inserted Text

This is hyperlink Click here

This is image

Program 2:

Write a HTML program to create student marks sheet preparation.

Aim : To Write a HTML program to create student marks sheet preparation.

Source Code :

<!DOCTYPE html>
<html>
<body bgcolor="lightblue" >
<center>
<h2>Student marks sheet</h2>
<table border="1" cellspacing="5">
<caption>Input marks</caption>
<tr>
<th rowspan="2">Name</th>
<th colspan="5">Scores</th>
</tr>
<tr>
<th>Zoology</th>
<th>Chemistry</th>
<th>c language</th>
<th>Maths</th>
<th>Java</th>
</tr>

<form>
<tr>
<td> <label for="studentName">Student Name:</label>
<input type="text" id="studentName" name="studentName" required><br></td>

<td> <label for="subject1">Subject 1:</label>


<input type="number" id="subject1" name="subject1" required><br></td>

2
<td> <label for="subject2">Subject 2:</label>
<input type="number" id="subject2" name="subject2" required><br></td>

<td> <label for="subject3">Subject 3:</label>


<input type="number" id="subject3" name="subject3" required><br></td>

<td> <label for="subject4">Subject 4:</label>


<input type="number" id="subject4" name="subject4" required><br></td>

<td> <label for="subject5">Subject 5:</label>


<input type="number" id="subject5" name="subject5" required><br></td>
</form>
</tr>
</table>
<p> <button type="button" onclick="calculateMarks()">Calculate</button></P>

<table id="result" border="1" cellspacing="4">


<tr>
<th>Result:</th>
</tr>
<tr>
<td>Total Marks: <span id="totalMarks">0</span></td>
</tr>
<tr>
<td>Average Marks: <span id="averageMarks">0</span></td>
</tr>
</table>
</center>

<script>
function calculateMarks() {
var subject1 = parseInt(document.getElementById("subject1").value) || 0;
var subject2 = parseInt(document.getElementById("subject2").value) || 0;
var subject3 = parseInt(document.getElementById("subject3").value) || 0;
var subject4 = parseInt(document.getElementById("subject4").value) || 0;
var subject5 = parseInt(document.getElementById("subject5").value) || 0;

var totalMarks = subject1 + subject2 + subject3 + subject4 + subject5;


var averageMarks = totalMarks / 5;

document.getElementById("totalMarks").innerText = totalMarks;
document.getElementById("averageMarks").innerText = averageMarks.toFixed(2);
}
</script>
</body>
</html>
3
Output :

Program 3:

Write an HTML program to explain String manipulation using functions.

Aim : To write an HTML program to explain String manipulation using functions.

Source code :
<!DOCTYPE html>
<html>
<head>

<title>Loyola Degree College String Manipulation</title>


</head>
<body>
<h1>Loyola Degree College String Manipulation</h1>

<?php
$collegeName = "loyola degree college";
echo "<p>Original: $collegeName</p>";

$uppercase = strtoupper($collegeName);
echo "<p>Uppercase: $uppercase</p>";

$lowercase = strtolower($collegeName);
4
echo "<p>Lowercase: $lowercase</p>";

$firstChar = $collegeName[0];
echo "<p>First Character: $firstChar</p>";

$lastChar = $collegeName[strlen($collegeName) - 1];


echo "<p>Last Character: $lastChar</p>";

$length = strlen($collegeName);
echo "<p>Length: $length</p>";

$reversed = strrev($collegeName);
echo "<p>Reversed: $reversed</p>";
?>
</body>
</html>

Output :

Program 5:

Write an HTML program to perform all arithmetic operations using Java scripts(JS).

Aim : To write an HTML program to perform all arithmetic operations using Java
scripts(JS).

Source code:
<!DOCTYPE html>
<html>
<head>
<title>Arithmetic Operations</title>
</head>
5
<body bgcolor="yellow">
<center>
<h2>Arithmetic Operations</h2>

<label for="num1">Number 1:</label>


<input type="text" id="num1" >
<br><br>

<label for="num2">Number 2:</label>


<input type="text" id="num2" >
<br><br>

<button onclick="add()">Addition</button> &nbsp;


<button onclick="subtract()">Subtraction</button> &nbsp;
<button onclick="multiply()">Multiplication</button> &nbsp;
<button onclick="modulo()">Modulo Division</button> &nbsp;

<p id="result">Result: </p>


</center>

<script>
function add() {
var num1 = parseFloat(document.getElementById('num1').value);
var num2 = parseFloat(document.getElementById('num2').value);
var result = num1 + num2;
document.getElementById('result').innerText = 'Result: ' + result;
}
function subtract() {
var num1 = parseFloat(document.getElementById('num1').value);
var num2 = parseFloat(document.getElementById('num2').value);
var result = num1 - num2;
document.getElementById('result').innerText = 'Result: ' + result;
}
function multiply() {
var num1 = parseFloat(document.getElementById('num1').value);
var num2 = parseFloat(document.getElementById('num2').value);
var result = num1 * num2;
document.getElementById('result').innerText = 'Result: ' + result;
}

function modulo() {
6
var num1 = parseFloat(document.getElementById('num1').value);
var num2 = parseFloat(document.getElementById('num2').value);
var result = num1 % num2;
document.getElementById('result').innerText = 'Result: ' + result;
}
</script>
</body>
</html>

Output :

Program 6:

Develop a HTML program from which accepts any Mathematical expression.

Aim : To develop a HTML program from which accepts any Mathematical expression.

Source Code :
<!DOCTYPE html>
<html>
<head>
<title>Mathematical Expression </title>
</head>
<body>
<center>

7
<h2>Mathematical Expressions</h2>
<label for="expression">Enter Mathematical Expression:</label>
<input type="text" id="expression" placeholder="e.g., 2 + 3 * (4 - 1)"> <br> <br>

<button onclick="evaluateExpression()">Calculate</button>

<p id="result">Result: </p>


</center>

<script>
function evaluateExpression() {
var expression = document.getElementById('expression').value;
try {
var result = eval(expression);
document.getElementById('result').innerText = 'Result: ' + result;
} catch (error) {
document.getElementById('result').innerText = 'Invalid Expression';
}
}
</script>
</body>
</html>

Outline :

8
9

You might also like